Class IDataContextExtensions
Extension methods for easier use of IDataContext.
Inheritance
Inherited Members
Namespace: TimeCockpit.Data
Assembly: TimeCockpit.Data.dll
Syntax
public static class IDataContextExtensions
Methods
DeleteObject(IDataContext, EntityObject)
Deletes a given EntityObject.
Declaration
public static void DeleteObject(this IDataContext dataContext, EntityObject entityObject)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context to use. |
EntityObject | entityObject | The EntityObject to delete. |
ExecuteAction(IDataContext, ModelAction, IEnumerable<Guid>, ModelEntityBase, EntityObject)
Executes an instance of a ModelAction.
Declaration
public static ActionResult ExecuteAction(this IDataContext dataContext, ModelAction action, IEnumerable<Guid> inputSetUuids, ModelEntityBase modelEntity, EntityObject parameter)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context. |
ModelAction | action | The action that sould be executed. |
System.Collections.Generic.IEnumerable<System.Guid> | inputSetUuids | The input set uuids on which an action should be executed. |
ModelEntityBase | modelEntity | The entity type of the input set. |
EntityObject | parameter | The parameter that is passed into the action. |
Returns
Type | Description |
---|---|
ActionResult | The output of the action |
ExecuteAction(IDataContext, ModelAction, IEnumerable<EntityObject>, ModelEntityBase, EntityObject)
Executes an instance of a ModelAction.
Declaration
public static ActionResult ExecuteAction(this IDataContext dataContext, ModelAction action, IEnumerable<EntityObject> inputSet, ModelEntityBase modelEntity, EntityObject parameter)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context. |
ModelAction | action | The action that sould be executed. |
System.Collections.Generic.IEnumerable<EntityObject> | inputSet | The input set on which an action should be executed. |
ModelEntityBase | modelEntity | The entity type of the input set. |
EntityObject | parameter | The parameter that is passed into the action. |
Returns
Type | Description |
---|---|
ActionResult | The output of the action |
ExecuteActionAsync(IDataContext, ModelAction, IEnumerable<Guid>, ModelEntityBase, EntityObject)
Executes an instance of a ModelAction.
Declaration
public static Task<ActionResult> ExecuteActionAsync(this IDataContext dataContext, ModelAction action, IEnumerable<Guid> inputSetUuids, ModelEntityBase modelEntity, EntityObject parameter)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context. |
ModelAction | action | The action that sould be executed. |
System.Collections.Generic.IEnumerable<System.Guid> | inputSetUuids | The input set uuids on which an action should be executed. |
ModelEntityBase | modelEntity | The entity type of the input set. |
EntityObject | parameter | The parameter that is passed into the action. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ActionResult> | The output of the action |
ExecuteActionAsync(IDataContext, ModelAction, IEnumerable<EntityObject>, ModelEntityBase, EntityObject)
Executes an instance of a ModelAction.
Declaration
public static Task<ActionResult> ExecuteActionAsync(this IDataContext dataContext, ModelAction action, IEnumerable<EntityObject> inputSet, ModelEntityBase modelEntity, EntityObject parameter)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context. |
ModelAction | action | The action that sould be executed. |
System.Collections.Generic.IEnumerable<EntityObject> | inputSet | The input set on which an action should be executed. |
ModelEntityBase | modelEntity | The entity type of the input set. |
EntityObject | parameter | The parameter that is passed into the action. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ActionResult> | The output of the action |
RefreshModelAsync(IDataContext)
Refresh the model using a async task.
Declaration
public static Task RefreshModelAsync(this IDataContext dataContext)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task representing the refresh operation. |
SaveObject(IDataContext, EntityObject)
Saves a given EntityObject.
Declaration
public static void SaveObject(this IDataContext dataContext, EntityObject entityObject)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context to use. |
EntityObject | entityObject | The EntityObject to save. |
Select(IDataContext, String, IEnumerable<QueryParameter>, SelectCache)
Performs a select.
Declaration
public static EntityObject[] Select(this IDataContext dataContext, string query, IEnumerable<QueryParameter> parameters = null, SelectCache cache = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | The data context. |
System.String | query | The TCQL query string. |
System.Collections.Generic.IEnumerable<QueryParameter> | parameters | The query parameters. |
SelectCache | cache | The select cache. |
Returns
Type | Description |
---|---|
EntityObject[] | Asynchronously returns the resulting entity objects. |
SelectAsync(IDataContext, String, IEnumerable<QueryParameter>, SelectCache)
Asynchronously performs a select.
Declaration
public static Task<EntityObject[]> SelectAsync(this IDataContext dataContext, string query, IEnumerable<QueryParameter> parameters = null, SelectCache cache = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | The data context. |
System.String | query | The TCQL query string. |
System.Collections.Generic.IEnumerable<QueryParameter> | parameters | The query parameters. |
SelectCache | cache | The select cache. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<EntityObject[]> | Asynchronously returns the resulting entity objects. |
SelectSingle(IDataContext, String, IEnumerable<QueryParameter>, SelectCache)
Asynchronously selects a single entity.
Declaration
public static EntityObject SelectSingle(this IDataContext dataContext, string query, IEnumerable<QueryParameter> parameters = null, SelectCache cache = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | The data context. |
System.String | query | The query. |
System.Collections.Generic.IEnumerable<QueryParameter> | parameters | The parameters. |
SelectCache | cache | The select cache. |
Returns
Type | Description |
---|---|
EntityObject | Returns the single entity object. |
SelectSingle(IDataContext, IEntityObject, Boolean)
Select single based on an existing IEntityObject.
Declaration
public static EntityObject SelectSingle(this IDataContext dataContext, IEntityObject entityObject, bool autoIncludeRelations = false)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context. |
IEntityObject | entityObject | Existing (proxy) entity object to (re-)select. |
System.Boolean | autoIncludeRelations | Indicates whether relations should be included. |
Returns
Type | Description |
---|---|
EntityObject | Single entity object or null if not found. |
SelectSingleAsync(IDataContext, String, IEnumerable<QueryParameter>, SelectCache)
Asynchronously selects a single entity.
Declaration
public static Task<EntityObject> SelectSingleAsync(this IDataContext dataContext, string query, IEnumerable<QueryParameter> parameters = null, SelectCache cache = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | The data context. |
System.String | query | The query. |
System.Collections.Generic.IEnumerable<QueryParameter> | parameters | The parameters. |
SelectCache | cache | The select cache. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<EntityObject> | Returns the single entity object. |
SelectSingleAsync(IDataContext, IEntityObject, Boolean)
Select single based on an existing IEntityObject.
Declaration
public static Task<EntityObject> SelectSingleAsync(this IDataContext dataContext, IEntityObject entityObject, bool autoIncludeRelations = false)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context. |
IEntityObject | entityObject | Existing (proxy) entity object to (re-)select. |
System.Boolean | autoIncludeRelations | Indicates whether relations should be included. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<EntityObject> | Single entity object or null if not found. |
UserHasAdminRole(IDataContext, Model)
Gets a value indicating whether the user is admin or not.
Declaration
public static bool UserHasAdminRole(this IDataContext dataContext, Model model = null)
Parameters
Type | Name | Description |
---|---|---|
IDataContext | dataContext | Data context to use. |
Model | model | The model that hold the permissions |
Returns
Type | Description |
---|---|
System.Boolean | True if APP_AdminPermission matches or is not found. |
Remarks
If the APP_AdminPermission is not found or system mode is enabled we assume admin.