Class BaseSQLWrapperExecuter<SW, T>
A base class for executing a sql wrapper and enumerating the results
Inherited Members
Namespace: LemonEdge.API.Entities.Helpers
Assembly: API.dll
Syntax
public abstract class BaseSQLWrapperExecuter<SW, T>
where SW : BaseSQLWrapperExecuter<SW, T>
Type Parameters
Name | Description |
---|---|
SW | The type of BaseSQLWrapperExecuter itself |
T | The type of item to be enumerated when the sql wrapper is executed |
Constructors
BaseSQLWrapperExecuter(ISQLWrapper, IEntityRetriever, IReadOnlyCache)
Creates a new BaseSQLWrapper for the specified sql wrapper
Declaration
public BaseSQLWrapperExecuter(ISQLWrapper sqlWrapper, IEntityRetriever retriever, IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
ISQLWrapper | sqlWrapper | The actual sql wrapper to execute |
IEntityRetriever | retriever | A context to execute the sql wrapper with |
IReadOnlyCache | cache | A local cache |
BaseSQLWrapperExecuter(Guid, IEntityRetriever, IReadOnlyCache)
Creates a new BaseSQLWrapper for the specified sql wrapper
Declaration
public BaseSQLWrapperExecuter(Guid sqlWrapperID, IEntityRetriever retriever, IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | sqlWrapperID | The unique global id of the sql wrapper to execute |
IEntityRetriever | retriever | A context to execute the sql wrapper with |
IReadOnlyCache | cache | A local cache |
BaseSQLWrapperExecuter(String, IEntityRetriever, IReadOnlyCache)
Creates a new BaseSQLWrapper for the specified sql wrapper
Declaration
public BaseSQLWrapperExecuter(string sqlWrapperName, IEntityRetriever retriever, IReadOnlyCache cache)
Parameters
Type | Name | Description |
---|---|---|
System.String | sqlWrapperName | The name of the sql wrapper to execute - must match exactly |
IEntityRetriever | retriever | A context to execute the sql wrapper with |
IReadOnlyCache | cache | A local cache |
Fields
_params
Declaration
protected Dictionary<string, string> _params
Field Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> |
_sqlWrapper
Declaration
protected ISQLWrapper _sqlWrapper
Field Value
Type | Description |
---|---|
ISQLWrapper |
_sqlWrapperID
Declaration
protected readonly Guid? _sqlWrapperID
Field Value
Type | Description |
---|---|
System.Nullable<System.Guid> |
_sqlWrapperName
Declaration
protected readonly string _sqlWrapperName
Field Value
Type | Description |
---|---|
System.String |
Properties
Cache
A local context cache
Declaration
public IReadOnlyCache Cache { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCache |
Filter
Any filters provided by the user through SetFilter(QueryableExecuter<T>) to be applied to this sql wrapper before executing it
Declaration
public QueryableExecuter<T> Filter { get; }
Property Value
Type | Description |
---|---|
QueryableExecuter<T> |
Parameters
The parameters for running this sql wrapper query
Declaration
public Dictionary<string, string> Parameters { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> |
Retriever
The context the sql wrapper will be executed against
Declaration
public IEntityRetriever Retriever { get; }
Property Value
Type | Description |
---|---|
IEntityRetriever |
Methods
AddAsOfDate(DateTimeOffset)
Adds an as of date for running the sql wrapper query as of a specified point in the past. If this is not set, it is automatically determined from the context in Retriever
Declaration
public virtual BaseSQLWrapperExecuter<SW, T> AddAsOfDate(DateTimeOffset asOfDate)
Parameters
Type | Name | Description |
---|---|---|
System.DateTimeOffset | asOfDate | The date to run this query as of in the past |
Returns
Type | Description |
---|---|
BaseSQLWrapperExecuter<SW, T> | This instance, for chaining commands |
AddCanvasID(Guid)
Adds the id of a canvas for running the sql wrapper query in. If this is not set, it is automatically determined from the context in Retriever
Declaration
public virtual BaseSQLWrapperExecuter<SW, T> AddCanvasID(Guid canvasID)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | canvasID | The canvas to run this sql wrapper in |
Returns
Type | Description |
---|---|
BaseSQLWrapperExecuter<SW, T> | This instance, for chaining commands |
AddParameter(String, Boolean)
Adds the specified value for the specified parameter
Declaration
public BaseSQLWrapperExecuter<SW, T> AddParameter(string paramName, bool paramValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | paramName | The unique name of the sql wrapper parameter (coming from ParameterName) |
System.Boolean | paramValue | The boolean value for this parameter |
Returns
Type | Description |
---|---|
BaseSQLWrapperExecuter<SW, T> | This instance, for chaining commands |
AddParameter<V>(String, V)
Adds the specified value for the specified parameter
Declaration
public BaseSQLWrapperExecuter<SW, T> AddParameter<V>(string paramName, V paramValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | paramName | The unique name of the sql wrapper parameter (coming from ParameterName) |
V | paramValue | The value for this parameter |
Returns
Type | Description |
---|---|
BaseSQLWrapperExecuter<SW, T> | This instance, for chaining commands |
Type Parameters
Name | Description |
---|---|
V | The type of value |
AddParameter<V>(String, Nullable<V>)
Adds the specified value for the specified parameter
Declaration
public BaseSQLWrapperExecuter<SW, T> AddParameter<V>(string paramName, V? paramValue)
where V : struct
Parameters
Type | Name | Description |
---|---|---|
System.String | paramName | The unique name of the sql wrapper parameter (coming from ParameterName) |
System.Nullable<V> | paramValue | The nullable value for this parameter |
Returns
Type | Description |
---|---|
BaseSQLWrapperExecuter<SW, T> | This instance, for chaining commands |
Type Parameters
Name | Description |
---|---|
V | The type of the value |
AddParameters(IReadOnlyDictionary<String, String>)
Adds the specified value for the specified parameter
Declaration
public BaseSQLWrapperExecuter<SW, T> AddParameters(IReadOnlyDictionary<string, string> parameters)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyDictionary<System.String, System.String> | parameters |
Returns
Type | Description |
---|---|
BaseSQLWrapperExecuter<SW, T> | This instance, for chaining commands |
ClearFilter()
Clears any existing filter for this SQL Wrapper Executer
Declaration
public BaseSQLWrapperExecuter<SW, T> ClearFilter()
Returns
Type | Description |
---|---|
BaseSQLWrapperExecuter<SW, T> | This instance, for chaining commands |
ClearParameters()
Clears all parameters
Declaration
public BaseSQLWrapperExecuter<SW, T> ClearParameters()
Returns
Type | Description |
---|---|
BaseSQLWrapperExecuter<SW, T> | This instance, for chaining commands |
Execute()
Executes this sql wrapper using the provided parameters and filter
Declaration
public abstract Task<IEnumerable<T>> Execute()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<T>> | An enumeration of the results for this sql wrapper execution |
ExecuteCount()
Executes the count of the results of this sql wrapper using the provided parameters and filter
Declaration
public abstract Task<int> ExecuteCount()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | The count of results for executing this sql wrapper with the provided parameters and filter |
GetFilter()
By default returns the current Filter specified for this sql wrapper executer.
Can be overridden by inheriting classes to provide a default filter if the current filter is null and has not been provided
Declaration
protected virtual QueryableExecuter<T> GetFilter()
Returns
Type | Description |
---|---|
QueryableExecuter<T> | The filters to be applicaed before executing this sql wrapper executer |
GetQueryArgumentsAndFilter()
Declaration
protected (string paramArguments, string queryFilter) GetQueryArgumentsAndFilter()
Returns
Type | Description |
---|---|
System.ValueTuple<System.String, System.String> |
GetWrapper()
Returns the SQL Wrapper to be executed.
This executer may have been created with just the id or name of a sql wrapper, in which case it has to load it from the cache before it can return it
Declaration
public Task<ISQLWrapper> GetWrapper()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ISQLWrapper> | The SQL Wrapper to be executed. |
ParametersAreValid()
Indicates if the parameters for running this sql wrapper executer are valid.
If invalid the GetQueryArgumentsAndFilter() method will throw an exception
Declaration
protected virtual bool ParametersAreValid()
Returns
Type | Description |
---|---|
System.Boolean | True if the current parameters for this query are valid, false if not |
SetFilter(QueryableExecuter<T>)
Sets the specified filter to be incorporated into the sql wrapper while executed to efficiently filter the results being returned
Declaration
public BaseSQLWrapperExecuter<SW, T> SetFilter(QueryableExecuter<T> filter)
Parameters
Type | Name | Description |
---|---|---|
QueryableExecuter<T> | filter | A QueryableExecuter holding the filter to be applied to this SQL Wrapper Executer before executing it |
Returns
Type | Description |
---|---|
BaseSQLWrapperExecuter<SW, T> | This instance, for chaining commands |