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
Elementrelationships
List<RelationshipReference>
CreateDataModelAsync(Element, List<RelationshipReference>?)
Create an element's tables and procedures
public Task CreateDataModelAsync(Element element, List<RelationshipReference>? relationships = null)
Parameters
element
Elementrelationships
List<RelationshipReference>
Returns
Delete(Element, Dictionary<string, object>)
public int Delete(Element element, Dictionary<string, object> primaryKeys)
Parameters
element
ElementprimaryKeys
Dictionary<string, object>
Returns
DeleteAsync(Element, Dictionary<string, object>)
Delete records based on filter.
public Task<int> DeleteAsync(Element element, Dictionary<string, object> filters)
Parameters
element
Elementfilters
Dictionary<string, object>
Returns
ExecuteBatchAsync(string, Guid?)
public Task<bool> ExecuteBatchAsync(string script, Guid? connectionId = null)
Parameters
Returns
GetAlterTableScriptAsync(Element)
public Task<string?> GetAlterTableScriptAsync(Element element)
Parameters
element
Element
Returns
GetCount(Element, Dictionary<string, object?>)
public int GetCount(Element element, Dictionary<string, object?> values)
Parameters
element
Elementvalues
Dictionary<string, object>
Returns
GetCountAsync(Element, Dictionary<string, object?>)
public Task<int> GetCountAsync(Element element, Dictionary<string, object?> filters)
Parameters
element
Elementfilters
Dictionary<string, object>
Returns
GetCreateTableScript(Element, List<RelationshipReference>?)
Build a structure script to create table
public string GetCreateTableScript(Element element, List<RelationshipReference>? relationships = null)
Parameters
element
Elementrelationships
List<RelationshipReference>
Returns
GetDataSet(DataAccessCommand, Guid?)
public DataSet GetDataSet(DataAccessCommand command, Guid? connectionId = null)
Parameters
command
DataAccessCommandconnectionId
Guid?
Returns
GetDataSetAsync(DataAccessCommand, Guid?, CancellationToken)
public Task<DataSet> GetDataSetAsync(DataAccessCommand command, Guid? connectionId = null, CancellationToken cancellationToken = default)
Parameters
command
DataAccessCommandconnectionId
Guid?cancellationToken
CancellationToken
Returns
GetDataTable(DataAccessCommand, Guid?)
public DataTable GetDataTable(DataAccessCommand dataAccessCommand, Guid? connectionId = null)
Parameters
dataAccessCommand
DataAccessCommandconnectionId
Guid?
Returns
GetDataTableAsync(DataAccessCommand, Guid?)
public Task<DataTable> GetDataTableAsync(DataAccessCommand dataAccessCommand, Guid? connectionId = null)
Parameters
dataAccessCommand
DataAccessCommandconnectionId
Guid?
Returns
GetDataTableAsync(Element, EntityParameters?)
public Task<DataTable> GetDataTableAsync(Element element, EntityParameters? parameters = null)
Parameters
element
Elementparameters
EntityParameters
Returns
GetDictionaryList(Element, EntityParameters?)
public List<Dictionary<string, object?>> GetDictionaryList(Element element, EntityParameters? parameters = null)
Parameters
element
Elementparameters
EntityParameters
Returns
GetDictionaryListAsync(DataAccessCommand, Guid?)
public Task<List<Dictionary<string, object?>>> GetDictionaryListAsync(DataAccessCommand command, Guid? connectionId = null)
Parameters
command
DataAccessCommandconnectionId
Guid?
Returns
- Task<List<Dictionary<string, object>>>
GetDictionaryListAsync(Element, EntityParameters?)
public Task<List<Dictionary<string, object?>>> GetDictionaryListAsync(Element element, EntityParameters? parameters = null)
Parameters
element
Elementparameters
EntityParameters
Returns
- Task<List<Dictionary<string, object>>>
GetDictionaryListResult(Element, EntityParameters?, bool)
public DictionaryListResult GetDictionaryListResult(Element element, EntityParameters? parameters = null, bool recoverTotalOfRecords = true)
Parameters
element
Elementparameters
EntityParametersrecoverTotalOfRecords
bool
Returns
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
Elementparameters
EntityParametersrecoverTotalOfRecords
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
Returns
GetFields(DataAccessCommand, Guid?)
public Dictionary<string, object?> GetFields(DataAccessCommand command, Guid? connectionId = null)
Parameters
command
DataAccessCommandconnectionId
Guid?
Returns
GetFields(Element, Dictionary<string, object>)
public Dictionary<string, object?> GetFields(Element element, Dictionary<string, object> primaryKeys)
Parameters
element
ElementprimaryKeys
Dictionary<string, object>
Returns
GetFieldsAsync(DataAccessCommand, Guid?)
public Task<Dictionary<string, object?>> GetFieldsAsync(DataAccessCommand command, Guid? connectionId = null)
Parameters
command
DataAccessCommandconnectionId
Guid?
Returns
GetFieldsAsync(Element, Dictionary<string, object>)
public Task<Dictionary<string, object?>> GetFieldsAsync(Element element, Dictionary<string, object> primaryKeys)
Parameters
element
ElementprimaryKeys
Dictionary<string, object>
Returns
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
ElementStructure basic from a table
parameters
EntityParametersshowLogInfo
boolRecords detailed log of each operation
delimiter
stringField 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
GetResultAsync(DataAccessCommand, Guid?)
Returns a single sql command value with parameters
public Task<object?> GetResultAsync(DataAccessCommand command, Guid? connectionId = null)
Parameters
command
DataAccessCommandconnectionId
Guid?
Returns
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
Insert(Element, Dictionary<string, object?>)
public void Insert(Element element, Dictionary<string, object?> values)
Parameters
element
Elementvalues
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
ElementBase element with the basic structure of the table
values
Dictionary<string, object>List of values to be stored in the database
Returns
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
DataAccessCommandconnectionId
Guid?
Returns
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
SetValues(Element, Dictionary<string, object?>, bool)
public CommandOperation SetValues(Element element, Dictionary<string, object?> values, bool ignoreResults = false)
Parameters
element
Elementvalues
Dictionary<string, object>ignoreResults
bool
Returns
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
ElementBase element with the basic structure of the table
values
Dictionary<string, object>List of values to be stored in the database
ignoreResults
boolBy 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
Returns
TableExistsAsync(string, Guid?)
Check if table exists in the database
public Task<bool> TableExistsAsync(string tableName, Guid? connectionId = null)
Parameters
Returns
Update(Element, Dictionary<string, object?>)
public int Update(Element element, Dictionary<string, object?> values)
Parameters
element
Elementvalues
Dictionary<string, object>
Returns
UpdateAsync(Element, Dictionary<string, object?>)
Update a record in the database
public Task<int> UpdateAsync(Element element, Dictionary<string, object?> values)
Parameters
element
Elementvalues
Dictionary<string, object>