DynamicRepository

It is used to access data from a program code.

During the work through DynamicRepository external functions for View automatically are caused and the history of change of record is formed.

DynamicRepository provides the following public methods:

# Name Signatures Comment
1 GetByView public static List GetByView(string name,FilterCriteriaSet filter,OrderByCriteriaSet order) Selecting from DB
2 GetByEntity public static List GetByEntity(string name,FilterCriteriaSet filter,OrderByCriteriaSet order) Selecting from DB
3 NewByView public static dynamic NewByView(string name) Creates empty object by metadata
4 NewByEntity public static dynamic NewByEntity(string name) Creates empty object by metadata
5 GetContainerByView public static ObservableEntityContainer GetContainerByView(string name,FilterCriteriaSet filter) Returns the container with possibility of tracking the changes. It can be used at any operations but it is more convenient for update.
6 GetContainerByEntity public static ObservableEntityContainer GetContainerByEntity(string name, FilterCriteriaSet filter) Returns the container with possibility of tracking the changes. It can be used at any operations but it is more convenient for update.
7 InsertByView public static void InsertByView(string name,List entities) Inserting data to DB
8 InsertByEntity public static void InsertByEntity(string name,List entities) Inserting data to DB
9 UpdateByView public static void UpdateByView(string name,List entities) Updating data to DB
10 UpdateByEntity public static void UpdateByEntity(string name,List entities) Updating data to DB
11 DeleteByView public static void DeleteByView(string name,List ids) Deleting data from DB
12 DeleteByEntity public static void DeleteByEntity(string name,List ids) Deleting data from DB
13 ViewToDictionary public static Dictionary<object, object> ViewToDictionary(string name,string valueColumnName) Returns Dictionary, wherekey is primary key of record,value - value of a column from the value ColumnName parameter.

Sorting

Sorting is described by the class OptimaJet.DynamicEntities.Query.OrderByCriteriaSet. For sorting by several fields use SortingExtension.

Example of simple sorting of "Name ASC":

С#: var sort = OrderByCriteriaSet.Asc("Name");

Example of simple sorting of "Name ASC, Sort DESC":

С#: var sort = SortingExtension.Desc(OrderByCriteriaSet.Asc("Name"), "Sort");

Filtering

Filters are described by the class OptimaJet.DynamicEntities.Query.FilterCriteriaSet.

Example of the simple filter:

C#: var filter = FilterCriteriaSet.And.Equal(3, "TypeId");

Filter AND:

C#: var filter = FilterCriteriaSet.And.Equal(3, "TypeId").Equal("A", "KindId");

Filter IN:

C#: var filter = FilterCriteriaSet.And.In(new List {"A", "B"}, "State");

Filter CUSTOM:

C#:

var query = "EXISTS (SELECT * FROM [dbo].[WorkflowEntityTransitionHistory] weth WHERE weth.ProcessId = Id AND weth.ExecutorIdentityId = @eiid)";

var filter = FilterCriteriaSet.And.Custom(query, new Dictionary<string, object> {{ "eiid",SecurityCache.CurrentUser.Id }});