Class WMDbContextUtils
Base class for DbContexts in World Modeler
Inherited Members
Namespace: Quantellia.WMServer.Base
Assembly: WMServer.dll
Syntax
public class WMDbContextUtils
Constructors
WMDbContextUtils(ModelBuilder, bool)
Create a new instance and set the ModelBuilder reference.
Declaration
public WMDbContextUtils(ModelBuilder mb, bool setDbEntityKey = true)
Parameters
Type | Name | Description |
---|---|---|
ModelBuilder | mb | The ModelBuilder object for the associated DbContext. |
bool | setDbEntityKey | If true, will specify that the abstract base class IDbEntity has key column "Id" and should not be mapped. |
Methods
CleanFullPath(string?)
This method cleans variations in ways the express the full path of an asset, including the Root directory.
Declaration
public static string CleanFullPath(string? src_path)
Parameters
Type | Name | Description |
---|---|---|
string | src_path | The original provided path |
Returns
Type | Description |
---|---|
string |
ConvertAssetPaths<T>(params Expression<Func<T, string>>[])
This performs the value conversions for fullPathName properties in a more compact manner.
Declaration
public void ConvertAssetPaths<T>(params Expression<Func<T, string>>[] expressions) where T : class, IWMAssetBaseDTO
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, string>>[] | expressions | A set of expressions (i.e. dr_dto => dr_dto.DataSourceID) which represent fullPathName references to other assets, and require value conversions. |
Type Parameters
Name | Description |
---|---|
T | An asset DTO type |
CreateDbContext<T>(string)
Declaration
public static DbContext CreateDbContext<T>(string connectionString) where T : DbContext
Parameters
Type | Name | Description |
---|---|---|
string | connectionString |
Returns
Type | Description |
---|---|
DbContext |
Type Parameters
Name | Description |
---|---|
T |
EncryptDecryptAssetProperty<T>(params Expression<Func<T, string>>[])
This performs the encrypt/decrypt conversions for secure properties in a more compact manner.
Declaration
public void EncryptDecryptAssetProperty<T>(params Expression<Func<T, string>>[] expressions) where T : class, IWMAssetBaseDTO
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, string>>[] | expressions | A set of expressions (i.e. ds_dto => ds_dto.ConnectionString) which represent secure properties, and must be encrypted when stored in the database. |
Type Parameters
Name | Description |
---|---|
T | An asset DTO type |
GetUniqueGUID<T>(Expression<Func<T, string>>, WMAppDbContext)
Generates a unique GUID for the provided column, provided that the entity is of a supported type.
Declaration
public static string GetUniqueGUID<T>(Expression<Func<T, string>> column, WMAppDbContext context) where T : class, IDbEntity
Parameters
Type | Name | Description |
---|---|---|
Expression<Func<T, string>> | column | An expression giving the column to search for unique strings under. (Example, x => x.ID) |
WMAppDbContext | context |
Returns
Type | Description |
---|---|
string |
Type Parameters
Name | Description |
---|---|
T | The type of the entity. Must be of a supported type. |
MapToTable<T>(string?)
Standard mapping of a World Modeler class that inherits from IDbEntity.
Declaration
public EntityTypeBuilder<T> MapToTable<T>(string? tableName = null) where T : class
Parameters
Type | Name | Description |
---|---|---|
string | tableName | Optional table name. If not specified or null, the class name of the T parameter will be used. |
Returns
Type | Description |
---|---|
EntityTypeBuilder<T> |
Type Parameters
Name | Description |
---|---|
T | The .NET model type to map to the specified table |
NewID()
Create a new GUID to use as an object ID.
Declaration
public static string NewID()
Returns
Type | Description |
---|---|
string |
NewID(string)
Creates a new GUID to use as an object ID if id
is not specified, otherwise returns id
. Cannot contain SeparatorString
Declaration
public static string NewID(string id)
Parameters
Type | Name | Description |
---|---|---|
string | id | The input ID |
Returns
Type | Description |
---|---|
string |
SetKey<T>(string[]?)
Set the column(s) that will be the key for the table generated for the class specified in the T parameter.
Declaration
public EntityTypeBuilder<T> SetKey<T>(string[]? key = null) where T : class
Parameters
Type | Name | Description |
---|---|---|
string[] | key |
Returns
Type | Description |
---|---|
EntityTypeBuilder<T> |
Type Parameters
Name | Description |
---|---|
T |
UrlDecode(string)
Decodes a single or multiple encoded Url string and returns the fully decoded results
Declaration
public static string UrlDecode(string encodedString)
Parameters
Type | Name | Description |
---|---|---|
string | encodedString | A single or multiple encoded Url string. |
Returns
Type | Description |
---|---|
string |