Show / Hide Table of Contents

Class SqlExtensions

Extension methods for getting correct sql statements for different types of database objects.

Inheritance
Object
SqlExtensions
Inherited Members
Object.Equals(Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: IRM.EntityFrameworkCore
Assembly: IRM.EntityFrameworkCore.dll
Syntax
public static class SqlExtensions

Methods

IsDefaultSchema(DbContext)

Gets if the default schema for the database is used.

Declaration
public static bool IsDefaultSchema(this DbContext context)
Parameters
Microsoft.EntityFrameworkCore.DbContext context

Returns
Boolean

true if the default schema for the database is used; otherwise false.

QuoteName(String, String)

Adds quotes around a name for creating safe SQL depending on the database.

Declaration
public static string QuoteName(this string name, string providerName)
Parameters
String name

The name to quote.

String providerName

The database provider to quote for.

Returns
String

A quoted name.

QuoteName<TContext>(String, TContext)

Adds quotes around a name for creating safe SQL depending on the database.

Declaration
public static string QuoteName<TContext>(this string name, TContext context)
    where TContext : DbContext
Parameters
String name

The name to quote.

TContext context

The Microsoft.EntityFrameworkCore.DbContext to quote for.

Returns
String

A quoted name.

Type Parameters
TContext

ToFullTableName(String, String, String)

Gets a table name for different database providers.

Declaration
public static string ToFullTableName(this string tableName, string schema, string providerName)
Parameters
String tableName

The name of the table.

String schema

The name of the schema.

String providerName

The name of the database provider.

Returns
String

A full table name formated for the providerName.

ToFullTableName<TContext>(String, TContext)

Gets a table name for different database providers.

Declaration
public static string ToFullTableName<TContext>(this string tableName, TContext context)
    where TContext : DbContext
Parameters
String tableName

The name of the table.

TContext context

The Microsoft.EntityFrameworkCore.DbContext that the table belongs to.

Returns
String

A full table name formated for the database provider used by the context.

Type Parameters
TContext

ToTableNameWhenSchemaIsNotSupported(String, DbContext)

Gets a table name for MySql with a prefix of schema_ if a schema is configured for the context.

Declaration
public static string ToTableNameWhenSchemaIsNotSupported(this string tableName, DbContext context)
Parameters
String tableName

The name of the table.

Microsoft.EntityFrameworkCore.DbContext context

The Microsoft.EntityFrameworkCore.DbContext that the table belongs to.

Returns
String

A table name for MySql.

Remarks

If default schema for context is "dbo" (default for SQL Server) the returned table name will only be tableName.

ToTableNameWhenSchemaIsNotSupported(String, String)

Gets a table name for MySql with a prefix of schema_ if a schema is configured.

Declaration
public static string ToTableNameWhenSchemaIsNotSupported(this string tableName, string schema)
Parameters
String tableName

The name of the table.

String schema

Returns
String

A table name for MySql.

Remarks

If schema is "dbo" (default for SQL Server) the returned table name will only be tableName.

Back to top Generated by DocFX