Table of Contents

Class EntityRepository

Namespace
JJMasterData.Commons.Data.Entity.Repository
Assembly
JJMasterData.Commons.dll
public class EntityRepository : IEntityRepository
Inheritance
EntityRepository
Implements
Inherited Members

Constructors

EntityRepository(IOptionsSnapshot<MasterDataCommonsOptions>, EntityProviderBase)

public EntityRepository(IOptionsSnapshot<MasterDataCommonsOptions> commonsOptions, EntityProviderBase provider)

Parameters

commonsOptions IOptionsSnapshot<MasterDataCommonsOptions>
provider EntityProviderBase

Methods

CreateDataModel(Element, List<RelationshipReference>?)

public void CreateDataModel(Element element, List<RelationshipReference>? relationships = null)

Parameters

element Element
relationships List<RelationshipReference>

CreateDataModelAsync(Element, List<RelationshipReference>?)

Create an element's tables and procedures

public Task CreateDataModelAsync(Element element, List<RelationshipReference>? relationships = null)

Parameters

element Element
relationships List<RelationshipReference>

Returns

Task

Delete(Element, Dictionary<string, object>)

public int Delete(Element element, Dictionary<string, object> primaryKeys)

Parameters

element Element
primaryKeys Dictionary<string, object>

Returns

int

DeleteAsync(Element, Dictionary<string, object>)

Delete records based on filter.

public Task<int> DeleteAsync(Element element, Dictionary<string, object> filters)

Parameters

element Element
filters Dictionary<string, object>

Returns

Task<int>

ExecuteBatchAsync(string, Guid?)

public Task<bool> ExecuteBatchAsync(string script, Guid? connectionId = null)

Parameters

script string
connectionId Guid?

Returns

Task<bool>

GetAlterTableScriptAsync(Element)

public Task<string?> GetAlterTableScriptAsync(Element element)

Parameters

element Element

Returns

Task<string>

GetCount(Element, Dictionary<string, object?>)

public int GetCount(Element element, Dictionary<string, object?> values)

Parameters

element Element
values Dictionary<string, object>

Returns

int

GetCountAsync(Element, Dictionary<string, object?>)

public Task<int> GetCountAsync(Element element, Dictionary<string, object?> filters)

Parameters

element Element
filters Dictionary<string, object>

Returns

Task<int>

GetCreateTableScript(Element, List<RelationshipReference>?)

Build a structure script to create table

public string GetCreateTableScript(Element element, List<RelationshipReference>? relationships = null)

Parameters

element Element
relationships List<RelationshipReference>

Returns

string

GetDataSet(DataAccessCommand, Guid?)

public DataSet GetDataSet(DataAccessCommand command, Guid? connectionId = null)

Parameters

command DataAccessCommand
connectionId Guid?

Returns

DataSet

GetDataSetAsync(DataAccessCommand, Guid?, CancellationToken)

public Task<DataSet> GetDataSetAsync(DataAccessCommand command, Guid? connectionId = null, CancellationToken cancellationToken = default)

Parameters

command DataAccessCommand
connectionId Guid?
cancellationToken CancellationToken

Returns

Task<DataSet>

GetDataTable(DataAccessCommand, Guid?)

public DataTable GetDataTable(DataAccessCommand dataAccessCommand, Guid? connectionId = null)

Parameters

dataAccessCommand DataAccessCommand
connectionId Guid?

Returns

DataTable

GetDataTableAsync(DataAccessCommand, Guid?)

public Task<DataTable> GetDataTableAsync(DataAccessCommand dataAccessCommand, Guid? connectionId = null)

Parameters

dataAccessCommand DataAccessCommand
connectionId Guid?

Returns

Task<DataTable>

GetDataTableAsync(Element, EntityParameters?)

public Task<DataTable> GetDataTableAsync(Element element, EntityParameters? parameters = null)

Parameters

element Element
parameters EntityParameters

Returns

Task<DataTable>

GetDictionaryList(Element, EntityParameters?)

public List<Dictionary<string, object?>> GetDictionaryList(Element element, EntityParameters? parameters = null)

Parameters

element Element
parameters EntityParameters

Returns

List<Dictionary<string, object>>

GetDictionaryListAsync(DataAccessCommand, Guid?)

public Task<List<Dictionary<string, object?>>> GetDictionaryListAsync(DataAccessCommand command, Guid? connectionId = null)

Parameters

command DataAccessCommand
connectionId Guid?

Returns

Task<List<Dictionary<string, object>>>

GetDictionaryListAsync(Element, EntityParameters?)

public Task<List<Dictionary<string, object?>>> GetDictionaryListAsync(Element element, EntityParameters? parameters = null)

Parameters

element Element
parameters EntityParameters

Returns

Task<List<Dictionary<string, object>>>

GetDictionaryListResult(Element, EntityParameters?, bool)

public DictionaryListResult GetDictionaryListResult(Element element, EntityParameters? parameters = null, bool recoverTotalOfRecords = true)

Parameters

element Element
parameters EntityParameters
recoverTotalOfRecords bool

Returns

DictionaryListResult

GetDictionaryListResultAsync(Element, EntityParameters?, bool)

Returns records from the database based on the filter.

public Task<DictionaryListResult> GetDictionaryListResultAsync(Element element, EntityParameters? parameters = null, bool recoverTotalOfRecords = true)

Parameters

element Element
parameters EntityParameters
recoverTotalOfRecords bool

Returns

Task<DictionaryListResult>

Returns a DictionaryListResult with the records found and the count of records at your data source.

GetElementFromTableAsync(string, Guid?)

Build a element from a existing table

public Task<Element> GetElementFromTableAsync(string tableName, Guid? connectionId = null)

Parameters

tableName string
connectionId Guid?

Returns

Task<Element>

GetFields(DataAccessCommand, Guid?)

public Dictionary<string, object?> GetFields(DataAccessCommand command, Guid? connectionId = null)

Parameters

command DataAccessCommand
connectionId Guid?

Returns

Dictionary<string, object>

GetFields(Element, Dictionary<string, object>)

public Dictionary<string, object?> GetFields(Element element, Dictionary<string, object> primaryKeys)

Parameters

element Element
primaryKeys Dictionary<string, object>

Returns

Dictionary<string, object>

GetFieldsAsync(DataAccessCommand, Guid?)

public Task<Dictionary<string, object?>> GetFieldsAsync(DataAccessCommand command, Guid? connectionId = null)

Parameters

command DataAccessCommand
connectionId Guid?

Returns

Task<Dictionary<string, object>>

GetFieldsAsync(Element, Dictionary<string, object>)

public Task<Dictionary<string, object?>> GetFieldsAsync(Element element, Dictionary<string, object> primaryKeys)

Parameters

element Element
primaryKeys Dictionary<string, object>

Returns

Task<Dictionary<string, object>>

GetListFieldsAsTextAsync(Element, EntityParameters?, bool, string)

Returns database records based on filter.

public Task<string> GetListFieldsAsTextAsync(Element element, EntityParameters? parameters = null, bool showLogInfo = false, string delimiter = "|")

Parameters

element Element

Structure basic from a table

parameters EntityParameters
showLogInfo bool

Records detailed log of each operation

delimiter string

Field delimiter in text file (default is pipe)

Returns

Task<string>

Returns a string with one record per line separated by the delimiter.

If no record is found it returns null.

*Warning:

  • Some special characters will be replaced:

    enter = #182;

    {delimiter} = #124;

  • Submitted formats:

    Numbers = en-US

    Date = yyyy-MM-dd HH:mm:ss

GetReadProcedureScript(Element)

Build a structure script to procedure of get

public string? GetReadProcedureScript(Element element)

Parameters

element Element

Returns

string

GetResultAsync(DataAccessCommand, Guid?)

Returns a single sql command value with parameters

public Task<object?> GetResultAsync(DataAccessCommand command, Guid? connectionId = null)

Parameters

command DataAccessCommand
connectionId Guid?

Returns

Task<object>

Remarks

It's used to return sql expressions commands

GetWriteProcedureScript(Element)

Build a structure script to procedure of set

public string? GetWriteProcedureScript(Element element)

Parameters

element Element

Returns

string

Insert(Element, Dictionary<string, object?>)

public void Insert(Element element, Dictionary<string, object?> values)

Parameters

element Element
values Dictionary<string, object>

InsertAsync(Element, Dictionary<string, object?>)

Add a record to the database. Return the id in the values ​​field as a reference

public Task InsertAsync(Element element, Dictionary<string, object?> values)

Parameters

element Element

Base element with the basic structure of the table

values Dictionary<string, object>

List of values ​​to be stored in the database

Returns

Task

Remarks

How to do: [key(database field name), value(value to be stored in the database)].

SetCommandAsync(DataAccessCommand, Guid?)

Execute the command in the database.

public Task SetCommandAsync(DataAccessCommand command, Guid? connectionId = null)

Parameters

command DataAccessCommand
connectionId Guid?

Returns

Task

Remarks

It's used to run scripts from data dictionary at importation files

SetCommandListAsync(IEnumerable<DataAccessCommand>, Guid?)

public Task<int> SetCommandListAsync(IEnumerable<DataAccessCommand> commandList, Guid? connectionId = null)

Parameters

commandList IEnumerable<DataAccessCommand>
connectionId Guid?

Returns

Task<int>

SetValues(Element, Dictionary<string, object?>, bool)

public CommandOperation SetValues(Element element, Dictionary<string, object?> values, bool ignoreResults = false)

Parameters

element Element
values Dictionary<string, object>
ignoreResults bool

Returns

CommandOperation

SetValuesAsync(Element, Dictionary<string, object?>, bool)

Set a record in the database. If it exists then update it, otherwise add. Include PK in Hashtable in case of indentity

public Task<CommandOperation> SetValuesAsync(Element element, Dictionary<string, object?> values, bool ignoreResults = false)

Parameters

element Element

Base element with the basic structure of the table

values Dictionary<string, object>

List of values to be stored in the database

ignoreResults bool

By default the values returned in the set procedures are returned by reference in the hashtable values object, if this ignoreResults parameter is true this action is ignored, improving performance

Returns

Task<CommandOperation>

NONE=-1, INSERT=0, UPDATE=1, DELETE=2

Remarks

How to do: [key(database field name), value(value to be stored in the database)].

TableExists(string, Guid?)

public bool TableExists(string tableName, Guid? connectionId = null)

Parameters

tableName string
connectionId Guid?

Returns

bool

TableExistsAsync(string, Guid?)

Check if table exists in the database

public Task<bool> TableExistsAsync(string tableName, Guid? connectionId = null)

Parameters

tableName string
connectionId Guid?

Returns

Task<bool>

Update(Element, Dictionary<string, object?>)

public int Update(Element element, Dictionary<string, object?> values)

Parameters

element Element
values Dictionary<string, object>

Returns

int

UpdateAsync(Element, Dictionary<string, object?>)

Update a record in the database

public Task<int> UpdateAsync(Element element, Dictionary<string, object?> values)

Parameters

element Element
values Dictionary<string, object>

Returns

Task<int>