Data access through ORM

PDF
Advanced

The back-end core components provide the following database access options:

  • access using the ORM model
  • direct access

This article covers database queries that use the ORM model.

ORM (Object-relational mapping) is a technology that lets you use object-oriented programming languages to manage data retrieved from the database. The purpose of ORM is to bind objects implemented in the code to the database table records.

The ORM data model implements data management via the following classes:

  • The Terrasoft.Core.Entities.EntitySchemaQuery class builds queries to retrieve the database table records. The queries apply the access permissions of the current user.
  • The Terrasoft.Core.Entities.Entity class accesses entities that represent records in the database table.

We recommend using the ORM model to access data, though the direct access to the database is also implemented in the back-end core components. Learn more about running direct database queries: Access data directly.

Configure a column path relative to the root schema 

Base a selection query that uses EntitySchemaQuery on the root schema. The root schema is the database table relative to which to build paths to the query columns, including the columns of joinable tables. To use a table column in a query, set the path to the column correctly.

Follow the principle of connection by lookup fields when building the column paths. Build the name of a column to add to the query as a chain of interconnected links. Each link must represent the context of the schema connected to the previous schema by a lookup column.

The template for configuring the path to a column in the N schema: 1SchemaContext.[...].NSchemaContext.LookupSchema'sColumnName.

Specify the column path using the direct connections 

The template for configuring the column path using the direct connections: LookupColumnName.LookupSchema'sColumnSchemaName.

Use direct connections if the connection lookup column is located in the main schema and links to the joinable schema. For example, a [City] root schema contains the [Country] lookup column. The column is connected to the [Country] lookup schema by the [Id] column.

The path to the column that contains the name of the country connected to the city, built using the direct connections: Country.Name. Where:

  • Country is the name of the lookup column in the [City] root schema. Links to the [Country] schema.
  • Name is the name of the column in the [Country] lookup schema.

Specify the column path using the reverse connections 

Unlike direct connections, reverse connections require the lookup field to join to be located in the joinable entity, not the main entity.

The template for configuring the column path using the reverse connections: [JoinableSchemaName:NameOfTheColumnToLinkTheJoinableSchema:NameOfTheColumnToLinkTheCurrentSchema].JoinableSchema'sColumnName.

The path to the name column of the account whose [City] field contains the [City] record selected in the query, built using the reverse connections: [Account:City:Id].Name. Where:

  • Account is the name of the joinable schema.
  • City is the name of the [Account] schema's column to connect the joinable schema.
  • Id is the name of the [City] schema's lookup column to connect the current schema.
  • Name is the value of the [Account] schema's lookup column.

If the schema's lookup column to connect the current schema is [Id], you do not have to specify it: [JoinableSchemaName:NameOfTheColumnToConnectTheJoinableSchema].JoinableSchema'sColumnName. For example, [Account:City].Name.

Retrieve data from the database 

Use the following classes to retrieve data from the database:

  • Terrasoft.Core.DB.Select retrieves data by accessing the database directly. Learn more: Access data directly.
  • Terrasoft.Core.Entities.EntitySchemaQuery retrieves database data using the ORM model.

The purpose of the Terrasoft.Core.Entities.EntitySchemaQuery class is to build selection queries for database table records. By default, you can retrieve up to 20 000 records in a query. This value can be modified in the MaxEntityRowCount setting in the ...\Terrasoft.WebApp\Web.config file.

Attention. However, we do not recommend modifying the MaxEntityRowCount setting. Doing so may lead to performance issues.

After you create and configure the class instance, Creatio will build a SELECT query to the application database. You can add columns, filters, and restriction conditions to the query. You can also set the parameters to output the query results in pagination mode. If needed, use the Terrasoft.Core.Entities.EntitySchemaQueryOptions class to set the parameters of a hierarchical query. Pass the same EntitySchemaQueryOptions instance as the GetEntityCollection() method parameter of the corresponding query to retrieve the results of various queries.

The Terrasoft.Core.Entities.EntitySchemaQuery class major features:

  • The resulting query applies the access permissions of the current user.
  • You can manage the current user's access permissions to the tables that JOIN SQL operator joined to the query.
  • The class lets you manage data of a cache repository or any repository you specify.

Creatio will cache the data retrieved from the database after running the query. Any repository that implements the Terrasoft.Core.Store.ICacheStore interface can serve as the query cache. By default, Creatio uses the session level cache with local storage. Define the query cache in the Cache property of the EntitySchemaQuery class instance. Set the key to access the query cache in the CacheItemName property. Learn more about Creatio repository levels: The object model of Creatio repositories.

As result of the query, is the Terrasoft.Nui.ServiceModel.DataContract.EntityCollection instance or the Terrasoft.Core.Entities.Entity class instance collection. Each Entity collection instance represents a string of data returned by the query.

Manage joined tables 

You can specify the schema join type of a query using the EntitySchemaQuery class. Use the JOIN operator to add the joinable schema column to the query.

The template for configuring the join type of the joinable schema column: SpecialCharacterOfTheJoinTypeNameOfTheColumnToConnectTheJoinableSchema.

Join types description
Join type
Special character of the join type
Use example
INNER JOIN
=
=Country.Name
LEFT OUTER JOIN
>
>Country.Name
RIGHT OUTER JOIN
<
<Country.Name
FULL OUTER JOIN
<>
<>Country.Name
CROSS JOIN
*
*Country.Name

By default, Creatio uses the LEFT OUTER JOIN type.

See the example that adds columns to a query using various join types below.

Add columns to a query
/* Create a query instance based on the City root schema. */
var esqResult = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "City");

/* Add the Country schema of the LEFT OUTER JOIN type to the query. */
esqResult.AddColumn("Country.Name");

/* Add the Country schema of the INNER JOIN type to the query. */
esqResult.AddColumn("=Country.Name");

/* Add the Country schema of the LEFT OUTER JOIN type and the Contact schema of the RIGHT OUTER JOIN type to the query. */
esqResult.AddColumn(">Country.<CreatedBy.Name");

As a result, Creatio will generate the SQL query.

SQL query
SELECT
    [Country].[Name] [Country.Name],
    [Country1].[Name] [Country1.Name],
    [CreatedBy].[Name] [CreatedBy.Name]
FROM
    [dbo].[City] [City]
    LEFT OUTER JOIN [dbo].[Country] [Country] ON ([Country].[Id] = [City].[CountryId])
    INNER JOIN [dbo].[Country] [Country1] ON ([Country1].[Id] = [City].[CountryId])
    LEFT OUTER JOIN [dbo].[Country] [Country2] ON ([Country2].[Id] = [City].[CountryId])
    RIGHT OUTER JOIN [dbo].[Contact] [CreatedBy] ON ([CreatedBy].[Id] = [Country2].[CreatedById])

If the query contains the root schema and joinable schemas that use record permissions, you will be able to apply the access permissions of the current user. The Terrasoft.Core.DB.QueryJoinRightLevel enumeration lists the ways to apply the record access permissions to the joinable schemas.

The ways to apply the access permissions to the joinable schema queries are as follows:

  • Apply always.
  • Apply only if the joinable schema query uses columns other than the primary column and primary display column. Usually, these are [Id] and [Name] columns.
  • Do not apply.

The JoinRightState query property determines the order to apply the access permissions. The Joined objects administering (QueryJoinRightLevel code) system setting determines the default value of the property. If the setting is empty, Creatio will apply the access permissions if the joinable schema query uses columns other than the primary column and the primary display column.

Manage the query filters 

Filter is sets of conditions applied when displaying the query data. In SQL terms, a filter is a separate predicate (condition) of the WHERE operator.

Filter structure
Filter = {[AggregationType] {<LeftExpression> | <LeftExpressionColumnPath>}
    <ComparisonType>
    {{<RightExpression> | {<RightExpressionColumnPath>,...}} | {<Macros>, [MacrosValue]}}
}

To create a simple filter in EntitySchemaQuery, use the CreateFilter() method that returns the instance of the EntitySchemaQueryFilter type. EntitySchemaQuery implements a series of overloads for this method. This lets you create filters with different incoming parameters. EntitySchemaQuery implements methods that create special kinds of filters.

The EntitySchemaQuery instance contains the Filters property that represents the filter collection of the query (the EntitySchemaQueryFilterCollection class instance). The EntitySchemaQueryFilterCollection class instance is a typed collection of the IEntitySchemaQueryFilterItem elements.

Follow this procedure to add a filter to the query:

  • Create a filter instance for the query (CreateFilter() methods, methods that create special kinds of filters).
  • Add the filter instance to the query filter collection (the Add() collection method).

By default, Creatio uses the logical AND operation to combine the filters added to the Filters collection. To implement the logical OR operation, use the LogicalOperation property of the Filters collection. This property takes the values of the LogicalOperationStrict enumeration and lets you specify the logical operation to combine the filters.

You can manage the filters that build the resulting dataset in the EntitySchemaQuery queries. Each element of the Filters collection includes the IsEnabled property that determines whether the element takes part in building the resulting query (true/false). Creatio defines the similar IsEnabled property for the Filters collection. If you set this property to false, the query filtering will be disabled, yet the query filters collection will remain unchanged. Thus, you can create a query filters collection and use various combinations without changing the collection itself.

Manage the database entity 

Terrasoft.Core.Entities.Entity is a class that implements the database entity management.

The purpose of the Terrasoft.Core.Entities.Entity class is to access the object that represents a database table record. You can also use the class for CRUD operations on the corresponding records.

Retrieve the database data based on the user's corresponding access permissions
Advanced

Note. The examples in this article are also implemented in the web service. The package that contains the web service implementation is attached in the Resources block.

Example 1 

Example. Create an EntitySchemaQuery instance.

CreateESQ method
public string CreateESQ()
{
    var result = "";
    /* Retrieve the instance of the object schema manager. */           
    EntitySchemaManager esqManager = SystemUserConnection.EntitySchemaManager;
    /* Retrieve the instance of the schema to set as root for the EntitySchemaQuery instance. */
    var rootEntitySchema = esqManager.GetInstanceByName("City") as EntitySchema;
    /* Create the EntitySchemaQuery instance that has the rootEntitySchema set as root. */
    var esqResult = new EntitySchemaQuery(rootEntitySchema);
    /* Add columns to select in the resulting query. */
    esqResult.AddColumn("Id");
    esqResult.AddColumn("Name");
    /* Retrieve the Select instance associated with the EntitySchemaQuery query. */
    Select selectEsq = esqResult.GetSelectQuery(SystemUserConnection);
    /* Retrieve the text of the EntitySchemaQuery instance's resulting query. */
    result = selectEsq.GetSqlText();
    return result;
}

Example 2 

Example. Clone the EntitySchemaQuery instance.

CreateESQClone method
public string CreateESQClone()
{
    var result = "";
    EntitySchemaManager esqManager = SystemUserConnection.EntitySchemaManager;
    var esqSource = new EntitySchemaQuery(esqManager, "Contact");
    esqSource.AddColumn("Id");
    esqSource.AddColumn("Name");
    /* Clone the EntitySchemaQuery instance from the esqSource instance. */
    var esqClone = new EntitySchemaQuery(esqSource);
    result = esqClone.GetSelectQuery(SystemUserConnection).GetSqlText();
    return result;
}

Example 3 

Example. Retrieve the query results.

GetEntitiesExample method
public string GetEntitiesExample()
{
    var result = "";
    /* Create a query to the City schema, add the Name column to the query. */
    var esqResult = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "City");
    var colName = esqResult.AddColumn("Name");

    /* Run the database query and retrieve the entire resulting objects collection. */
    var entities = esqResult.GetEntityCollection(UserConnection);
    for (int i=0; i < entities.Length; i++) {
        result += entities[i].GetColumnValue(colName.Name).ToString();
        result += "\n";
    }
    
    /* Run the database query and retrieve the object that has the set identifier. */
    var entity = esqResult.GetEntity(UserConnection, new Guid("100B6B13-E8BB-DF11-B00F-001D60E938C6"));
    result += "\n";
    result += entity.GetColumnValue(colName.Name).ToString();
    return result;
}

Example 4 

Example. Use the EntitySchemaQuery query cache.

UsingCacheExample method
public Collection<string> UsingCacheExample()
{
    /* Create a query to the City schema, add the Name column to the query. */
    var esqResult = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "City");
    esqResult.AddColumn("Name");

    /* Define the key the cache will use to store the query results. Creatio will use the session level Creatio cache with local storage since the Cache object property is not redefined. */
    esqResult.CacheItemName = "EsqResultItem";

    /* The collection to place the query results. */
    var esqCityNames = new Collection<string>();

    /* The collection to place the cached query results. */
    var cachedEsqCityNames = new Collection<string>();

    /* Run the database query and retrieve the resulting objects collection. Creatio will cache the query results after this operation. */
    var entities = esqResult.GetEntityCollection(UserConnection);

    /* Process the query results and populate the esqCityNames collection. */
    foreach (var entity in entities)
    {
        esqCityNames.Add(entity.GetTypedColumnValue<string>("Name"));
    }

    /* Retrieve the link to the esqResult query cache as a data table in memory using the CacheItemName key. */
    var esqCacheStore = esqResult.Cache[esqResult.CacheItemName] as DataTable;

    /* Populate the cachedEsqCityNames collection using the query cache values. */
    if (esqCacheStore != null)
    {
        foreach (DataRow row in esqCacheStore.Rows)
        {
            cachedEsqCityNames.Add(row[0].ToString());
        }
    }
    return cachedEsqCityNames;
}

Example 5 

Example. Use the additional settings of the EntitySchemaQuery query.

UsingCacheExample method
public Collection<string> ESQOptionsExample()
{
    /* Create a query instance that has the City root schema. */
    var esqCities = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "City");
    esqCities.AddColumn("Name");

    /* Create a query that has the Country root schema. */
    var esqCountries = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "Country");
    esqCountries.AddColumn("Name");

    /* Create an instance of settings to return first 5 strings in the query. */
    var esqOptions = new EntitySchemaQueryOptions()
    {
        PageableDirection = PageableSelectDirection.First,
        PageableRowCount = 5,
        PageableConditionValues = new Dictionary<string, object>()
    };

    /* Retrieve the city collection that contains the first 5 cities of the resulting dataset. */
    var cities = esqCities.GetEntityCollection(UserConnection, esqOptions);

    /* Retrieve the country collection that contains the first 5 countries of the resulting dataset. */
    var countries = esqCountries.GetEntityCollection(UserConnection, esqOptions);
        var esqStringCollection = new Collection<string>();
    foreach (var entity in cities)
    {
        esqStringCollection.Add(entity.GetTypedColumnValue<string>("Name"));
    }
    foreach (var entity in countries)
    {
        esqStringCollection.Add(entity.GetTypedColumnValue<string>("Name"));
    }
    return esqStringCollection;
}
Manage the database entities
Advanced

Note. Examples 1-5 in this article are also implemented in the web service. The package that contains the web service implementation is attached in the Resources block.

Example 1 

Example. Retrieve the value of the City schema column whose name is Name.

GetEntityColumnData method
public string GetEntityColumnData()
{
    var result = "";
    /* Create a query to the City schema, add the Name column to the query. */
    var esqResult = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "City");
    var colName = esqResult.AddColumn("Name");
    /* Run the database query and retrieve the object that has the set identifier. You can retrieve the object UId from the browser navigation bar after opening the section record page. */
    var entity = esqResult.GetEntity(UserConnection, new Guid("100B6B13-E8BB-DF11-B00F-001D60E938C6"));
    /* Retrieve the object column value. */
    result += entity.GetColumnValue(colName.Name).ToString();
    return result;
}

Example 2 

Example. Retrieve the name collection of the City schema columns.

GetEntityColumns method
public IEnumerable<string> GetEntityColumns()
{
    /* Create a data string object of the City schema based on the schema identifier retrieved from the database. */
    var entity = new Entity(UserConnection, new Guid("5CA90B6A-93E7-4448-BEFE-AB5166EC2CFE"));
    /* Retrieve the object that has the set identifier from the database. You can retrieve the object UId from the browser navigation bar after opening the section record page. */
    entity.FetchFromDB(new Guid("100B6B13-E8BB-DF11-B00F-001D60E938C6"),true);
    /* Retrieve the name collection of the object columns. */
    var result = entity.GetColumnValueNames();
    return result;
}

Example 3 

Example. Delete the Order schema records from the database.

DeleteEntity method
public bool DeleteEntity()
{
    /* Create a query to the Order schema, add all schema columns to the query. */
    var esqResult = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "Order");
    esqResult.AddAllSchemaColumns();
    /* Run the database query and retrieve the object that has the set identifier. You can retrieve the object UId from the browser navigation bar after opening the section record page. */
    var entity = esqResult.GetEntity(UserConnection, new Guid("e3bfa32f-3fe9-4bae-9332-16c162c51e0d"));
    /* Delete the object from the database. */
    entity.Delete();
    /* Check if the object that has the set identifier exists in the database. */
    var result = entity.ExistInDB(new Guid("e3bfa32f-3fe9-4bae-9332-16c162c51e0d"));
    return result;
}

Example 4 

Example. Change the order status.

UpdateEntity method
public bool UpdateEntity()
{
    /* Create a query to the Order schema, add all schema columns to the query. */
    var esqResult = new EntitySchemaQuery(UserConnection.EntitySchemaManager, "Order");
    esqResult.AddAllSchemaColumns();
    /* Run the database query and retrieve the object that has the set identifier. You can retrieve the object UId from the browser navigation bar after opening the section record page. */
    var entity = esqResult.GetEntity(UserConnection, new Guid("58be5223-715d-4b16-a5c4-e3d4ec0412d9"));
    /* Create the data string object of the OrderStatus schema. */
    var statusSchema = UserConnection.EntitySchemaManager.GetInstanceByName("OrderStatus");
    var newStatus = statusSchema.CreateEntity(UserConnection);
    /* Retrieve the object that has the set identifier from the database. */
    newStatus.FetchFromDB("Name", "4. Completed");
    /* Assign the new value to the StatusId column. */
    entity.SetColumnValue("StatusId", newStatus.GetTypedColumnValue<Guid>("Id"));
    /* Save the modified object to the database. */
    var result = entity.Save();
    return result;
}

Example 5 

Example. Add the city that has the specified name and connect it to the specified country.

UpdateEntity method
public bool InsertEntity(string city, string country)
{
    city = city ?? "unknown city";
    country = country ?? "unknown country";
    var citySchema = UserConnection.EntitySchemaManager.GetInstanceByName("City");
    var entity = citySchema.CreateEntity(UserConnection);
    entity.FetchFromDB("Name", city);
    /* Set the default values for the object columns. */
    entity.SetDefColumnValues();
    var contryEntity = new Entity(UserConnection, new Guid("09FCE1F8-515C-4296-95CD-8CD93F79A6CF"));
    contryEntity.FetchFromDB("Name", country);
    /* Assign the passed city name to the Name column. */
    entity.SetColumnValue("Name", city);
    /* Assign the passed country UId to the CountryId column. */
    entity.SetColumnValue("CountryId", contryEntity.GetTypedColumnValue<Guid>("Id"));
    var result = entity.Save();
    return result;
}

Example 6 

Example. Create a contact that has the "User01" name.

EntitySchema contactSchema = UserConnection.EntitySchemaManager.GetInstanceByName("Contact");
Entity contactEntity = contactSchema.CreateEntity(UserConnection);
contactEntity.SetDefColumnValues();
contactEntity.SetColumnValue("Name", "User01");
contactEntity.Save();

Example 7 

Example. Change the contact name to "User02".

EntitySchema entitySchema = UserConnection.EntitySchemaManager.GetInstanceByName("Contact");
Entity entity = entitySchema.CreateEntity(UserConnection);
if (!entity.FetchFromDB(some_id) {
    return false;
}
entity.SetColumnValue("Name", "User02");
return entity.Save();

Example 8 

Example. Delete the contact that has the "User02" name.

EntitySchema entitySchema = UserConnection.EntitySchemaManager.GetInstanceByName("Contact");
Entity entity = entitySchema.CreateEntity(UserConnection);
var fetchConditions = new Dictionary<string, object> {
    {"Name", "User02"}
};
if (entity.FetchFromDB(fetchConditions)) {
    entity.Delete();
}
EntitySchemaQuery class
Advanced

Namespace Terrasoft.Core.Entities.

The Terrasoft.Core.Entities.EntitySchemaQuery class is used to build queries for selecting records in Creatio database tables. As a result of creating and configuring the instance of this class, the SELECT SQL-expression query to the application database will be built. You can add the needed icons, filtering, and restriction conditions to the query.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaQuery class.

Constructors 

EntitySchemaQuery(EntitySchema rootSchema)

Creates a class instance, where the EntitySchema passed instance is set as a root schema. The manager of the passed-in instance of the root schema is set as the schema manager.

EntitySchemaQuery(EntitySchemaManager entitySchemaManager, string sourceSchemaName)

Creates a class instance with the specified EntitySchemaManager and the root schema passed as an argument.

EntitySchemaQuery(EntitySchemaQuery source)

Creates a class instance that is a clone of the instance passed as an argument.

Properties 

Cache Terrasoft.Core.Store.ICacheStore

The query cache.

CacheItemName string

Name of the cache item.

CanReadUncommitedData bool

Determines whether the query results will include the data for which the transaction is not completed.

Caption Terrasoft.Common.LocalizableString

Header.

ChunkSize int

The number of strings in one chunk.

Columns Terrasoft.Core.Entities.EntitySchemaQueryColumnCollection

Collection of columns of the current entity schema query.

DataValueTypeManager DataValueTypeManager

Manager of the data type values.

EntitySchemaManager Terrasoft.Core.Entities.EntitySchemaManager

Entity schema manager.

Filters Terrasoft.Core.Entities.EntitySchemaQueryFilterCollection

Collection of filters of the current entity schema query.

HideSecurityValue bool

Determines whether the values of the encrypted columns will be hidden.

IgnoreDisplayValues bool

Determines whether the displayed column values will be used in the query.

IsDistinct bool

Indicates whether duplicates in the resulting data set should be removed.

IsInherited bool

Indicates whether the query is inherited.

JoinRightState QueryJoinRightLevel

Determines the conditions for applying permissions when using related tables if the schema is managed by records.

Manager Terrasoft.Core.IManager

Schema manager.

ManagerItem Terrasoft.Core.IManagerItem

Manager element.

Name string

Name.

ParentCollection Terrasoft.Core.Entities.EntitySchemaQueryCollection

A collection of queries to which the current request to the object schema belongs.

ParentEntitySchema Terrasoft.Core.Entities.EntitySchema

Parent schema of the query.

PrimaryQueryColumn Terrasoft.Core.Entities.EntitySchemaQueryColumn

The column created from the primary column of the root schema Initialized during the first access.

QueryOptimize bool

Allows using query optimization./p>

RootSchema Terrasoft.Core.Entities.EntitySchema

The root schema.

RowCount int

Number of rows that are returned by the query..

SchemaAliasPrefix string

The prefix used to create schema alias.

SkipRowCount int

Number of rows to skip when returning the query result.

UseAdminRights bool

The parameter that defines whether permissions will be taken into account when constructing a data acquisition request.

UseLocalization bool

Determines whether localizable data will be used.

UseOffsetFetchPaging bool

Determines whether the per-page returning of the query result is available.

UseRecordDeactivation bool

Determines whether data will be excluded from filtering.

Methods 

void AddAllSchemaColumns(bool skipSystemColumns)

The object schema adds all the columns of the root schema in the column collection of the current query.

EntitySchemaQueryColumn AddColumn(string columnPath, AggregationTypeStrict aggregationType, out EntitySchemaQuery subQuery)
void AddColumn(EntitySchemaQueryColumn queryColumn)
EntitySchemaQueryColumn AddColumn(string columnPath)
EntitySchemaQueryColumn AddColumn(EntitySchemaQueryFunction function)
EntitySchemaQueryColumn AddColumn(object parameterValue, DataValueType parameterDataValueType)
EntitySchemaQueryColumn AddColumn(EntitySchemaQuery subQuery)

Creates and inserts a column in the current entity schema query.

Parameters
columnPath path to the schema column in relation to the root schema
aggregationType the type of aggregating function. The enumeration type values of the Terrasoft.Common.AggregationTypeStrict aggregate function are passed as a parameter
subQuery reference to the created subquery placed in the column
queryColumn the EntitySchemaQueryColumn instance to be added to the column collection of the current query
function the EntitySchemaQueryFunction function instance
parameterValue the value of the parameter added to the query as a column
parameterDataValueType the type of parameter value added to the query as a column
void ClearCache()

Clears the cache of the current query.

static void ClearDefCache(string cacheItemName)

Removes the item with the specified cacheItemName name from the cache of the query.

object Clone()

Creates a clone of the current EntitySchemaQuery instance.

EntitySchemaQueryExpression CreateAggregationEntitySchemaExpression(string leftExprColumnPath, AggregationTypeStrict leftExprAggregationType)

Returns expression of the aggregated function with the specified aggregation type from the Terrasoft.Common.AggregationTypeStrict enumeration for the column, located at the leftExprColumnPath specified path.

static EntitySchemaQueryExpression CreateParameterExpression(object parameterValue)
static EntitySchemaQueryExpression CreateParameterExpression(object parameterValue, DataValueType valueType)
static EntitySchemaQueryExpression CreateParameterExpression(object parameterValue, string displayValue, DataValueType valueType)

Creates an expression for the query parameter.

Parameters
parameterValue the type of the parameter
valueType the type of the parameter value
displayValue the parameter displayed value
static IEnumerable CreateParameterExpressions(DataValueType valueType, params object[] parameterValues)
static IEnumerable CreateParameterExpressions(DataValueType valueType, IEnumerable<object> parameterValues)

Creates an expression collection for the query parameters with a certain DataValueType type of data.

static EntitySchemaQueryExpression CreateSchemaColumnExpression(EntitySchemaQuery parentQuery, EntitySchema rootSchema, string columnPath, bool useCoalesceFunctionForMultiLookup, bool useDisplayValue)
static EntitySchemaQueryExpression CreateSchemaColumnExpression(EntitySchema rootSchema, string columnPath, bool useCoalesceFunctionForMultiLookup)
EntitySchemaQueryExpression CreateSchemaColumnExpression(string columnPath, bool useCoalesceFunctionForMultiLookup)

Returns the expression of the entity schema column.

Parameters
parentQuery the entity schema query for which the column expression is created
rootSchema the root schema
columnPath path to the schema column in relation to the root schema
useCoalesceFunctionForMultiLookup indicates whether to use the COALESCE function for the column of the lookup type. Optional parameter, set to false by default
useDisplayValue indicates whether to use the displayed value for the column. Optional parameter, set to false by default
Enumerable CreateSchemaColumnExpressions(params string[] columnPaths)
IEnumerable CreateSchemaColumnExpressions(IEnumerable columnPaths, bool useCoalesceFunctionForMultiLookup)

Returns the collection of column expressions of the entity schema query by the specified columnPaths. collection of paths to columns.

IEnumerable CreateSchemaColumnExpressionsWithoutCoalesce(params string[] columnPaths)

Returns the collection of column expressions of the entity schema query by the specified array of paths to columns. If it is a column of the multilookup type, the COALESCE function does not apply to its values.

static EntitySchemaQueryExpression CreateSchemaColumnQueryExpression(string columnPath, EntitySchema rootSchema, EntitySchemaColumn schemaColumn, bool useDisplayValue)
static EntitySchemaQueryExpression CreateSchemaColumnQueryExpression(string columnPath, EntitySchema rootSchema, bool useDisplayValue)

Returns the expression of the entity schema query by the specified path to column, root schema and schema column instance. You can define which column value type to use in the expression – either the stored value or the displayed value.

EntitySchemaQueryExpression CreateSubEntitySchemaExpression(string leftExprColumnPath)

Returns the expression of entity schema subquery for the column located at the specified leftExprColumnPath path.

EntitySchemaAggregationQueryFunction CreateAggregationFunction(AggregationTypeStrict aggregationType, string columnPath)

Returns the EntitySchemaAggregationQueryFunction aggregation function instance with the specified type of aggregation from the Terrasoft.Common.AggregationTypeStrict enumeration for the column at the specified columnPath path in relation to the root schema.

EntitySchemaCaseNotNullQueryFunction CreateCaseNotNullFunction(params EntitySchemaCaseNotNullQueryFunctionWhenItem[] whenItems)

Returns the instance of the CASE EntitySchemaCaseNotNullQueryFunction function for the specified EntitySchemaCaseNotNullQueryFunctionWhenItem array of condition expressions.

EntitySchemaCaseNotNullQueryFunctionWhenItem CreateCaseNotNullQueryFunctionWhenItem(string whenColumnPath, object thenParameterValue)

Returns an expression instance for the sql construct of the WHEN <Expression_1> IS NOT NULL THEN <Expression_2> view

Parameters
whenColumnPath path to the column that contains the expression of the WHEN clause
thenParameterValue path to the column that contains the expression of the THEN clause
EntitySchemaCastQueryFunction CreateCastFunction(string columnPath, DBDataValueType castType)

Returns an instance of the CAST EntitySchemaCastQueryFunction function for the column expression located at the specified columnPath path relative to the root schema and the specified DBDataValueType target data type.

EntitySchemaCoalesceQueryFunction CreateCoalesceFunction(params string[] columnPaths)
static EntitySchemaCoalesceQueryFunction CreateCoalesceFunction(EntitySchemaQuery parentQuery, EntitySchema rootSchema, params string[] columnPaths)
static EntitySchemaCoalesceQueryFunction CreateCoalesceFunction(EntitySchema rootSchema, params string[] columnPaths)

Returns the function instance returning the first expression that is other than null from the list of arguments for the specified columns.

Parameters
columnPaths array of paths to columns in relation to the root schema
parentQuery query to the entity schema, for which the function instance is created
rootSchema the root schema
EntitySchemaConcatQueryFunction CreateConcatFunction(params EntitySchemaQueryExpression[] expressions)

Returns a function instance for generating a string that is the result of combining the string values of function arguments for the specified EntitySchemaQueryExpression array of expressions.

EntitySchemaDatePartQueryFunction CreateDatePartFunction(EntitySchemaDatePartQueryFunctionInterval interval, string columnPath)

Returns the DATEPART instance of the EntitySchemaDatePartQueryFunction function that determines the date interval specified by the EntitySchemaDatePartQueryFunctionInterval enumeration (month, day, hour, year, week day...) for the value of column located at the specified path in relation to the root schema.

EntitySchemaDatePartQueryFunction CreateDayFunction(string columnPath)

Returns an instance of the EntitySchemaDatePartQueryFunction function that determines the Day date range for a column value located at the specified path in relation to the root schema.

EntitySchemaDatePartQueryFunction CreateHourFunction(string columnPath)

Returns an instance of the EntitySchemaDatePartQueryFunction function that returns a part of the Hour date for a column value located at the specified path in relation to the root schema.

EntitySchemaDatePartQueryFunction CreateHourMinuteFunction(string columnPath)

Returns an instance of the EntitySchemaDatePartQueryFunction function that returns a part of the Minute date for a column value located at the specified path in relation to the root schema.

EntitySchemaDatePartQueryFunction CreateMonthFunction(string columnPath)

Returns an instance of the EntitySchemaDatePartQueryFunction function that returns a part of the Month date for a column value located at the specified path in relation to the root schema.

EntitySchemaDatePartQueryFunction CreateWeekdayFunction(string columnPath)

Returns an instance of the EntitySchemaDatePartQueryFunction function that returns a part of the [Week day] date for a column value located at the specified path in relation to the root schema.

EntitySchemaDatePartQueryFunction CreateWeekFunction(string columnPath)

Returns an instance of the EntitySchemaDatePartQueryFunction function that returns a part of the Week date for a column value located at the specified path in relation to the root schema.

EntitySchemaDatePartQueryFunction CreateYearFunction(string columnPath)

Returns an instance of the EntitySchemaDatePartQueryFunction function that returns a part of the Year date for a column value located at the specified path in relation to the root schema.

EntitySchemaIsNullQueryFunction CreateIsNullFunction(string checkColumnPath, string replacementColumnPath)

Returns the instance of the EntitySchemaIsNullQueryFunction function for columns with values to check and substitute located at specified paths in relation to the root schema.

EntitySchemaLengthQueryFunction CreateLengthFunction(string columnPath)
EntitySchemaLengthQueryFunction CreateLengthFunction(params EntitySchemaQueryExpression[] expressions)

Creating an instance of the LEN function (the function for returning the length of expression) for the column expression at the specified path in relation to the root schema or for the specified expression array.

EntitySchemaTrimQueryFunction CreateTrimFunction(string columnPath)
EntitySchemaTrimQueryFunction CreateTrimFunction(params EntitySchemaQueryExpression[] expressions)

Creating an instance of the TRIM function (the function for removing all leading and trailing whitespace from expression) for the column expression at the specified path in relation to the root schema or for the specified expression array.

EntitySchemaUpperQueryFunction CreateUpperFunction(string columnPath)

Returns an instance of the EntitySchemaUpperQueryFunction function that converts all the argument expression characters into upper case. The column expression located at the specified path relative to the root schema is specified as the argument.

EntitySchemaCurrenddateQueryFunction CreateCurrenddateFunction()

Returns an instance of the EntitySchemaCurrentDateQueryFunction function that defines the current date.

EntitySchemaCurrenddateTimeQueryFunction CreateCurrenddateTimeFunction()

Returns an instance of the EntitySchemaCurrentDateTimeQueryFunction function that returns the current date and time.

EntitySchemaCurrentTimeQueryFunction CreateCurrentTimeFunction()

Returns the instance of the EntitySchemaCurrentTimeQueryFunction function that defines the current time.

EntitySchemaCurrentUserAccountQueryFunction CreateCurrentUserAccountFunction()

Returns the instance of the EntitySchemaCurrentUserAccountQueryFunction function that defines the account Id of the current user.

EntitySchemaCurrentUserContactQueryFunction CreateCurrentUserContactFunction()

Returns the instance of the EntitySchemaCurrentUserContactQueryFunction function that defines the contact Id of the current user.

EntitySchemaCurrentUserQueryFunction CreateCurrentUserFunction()

Returns the instance of the EntitySchemaCurrentUserQueryFunction function that defines the current user.

EntitySchemaQueryFilter CreateExistsFilter(string rightExpressionColumnPath)

Creates the Exists by the specified condition type comparison filter and sets the column expression located at the rightExpressionColumnPath specified path as the testing value.

IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, string leftExpressionColumnPath, params string[] rightExpressionColumnPaths)
IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, string leftExpressionColumnPath, EntitySchemaQueryExpression rightExpression)
IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, string leftExpressionColumnPath, EntitySchemaQueryFunction rightExpressionValue)
IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, EntitySchemaQueryExpression leftExpression, EntitySchemaQueryMacrosType macrosType, int rightValue)
IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, EntitySchemaQueryExpression leftExpression, EntitySchemaQueryMacrosType macrosType, DateTime rightValue)
IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, EntitySchemaQueryExpression leftExpression, EntitySchemaQueryMacrosType macrosType, DayOfWeek rightValue)
IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, string leftExpressionColumnPath, EntitySchemaQueryMacrosType macrosType, int rightValue)IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, string leftExpressionColumnPath, EntitySchemaQueryMacrosType macrosType, DateTime rightValue
)IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, string leftExpressionColumnPath, EntitySchemaQueryMacrosType macrosType, DayOfWeek rightValue)IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, string leftExpressionColumnPath, EntitySchemaQuery rightExpressionValue)
EntitySchemaQueryFilter CreateFilter(FilterComparisonType comparisonType, string leftExprColumnPath, AggregationTypeStrict leftExprAggregationType, int rightExprParameterValue)
EntitySchemaQueryFilter CreateFilter(FilterComparisonType comparisonType, string leftExprColumnPath, AggregationTypeStrict leftExprAggregationType, double rightExprParameterValue)
EntitySchemaQueryFilter CreateFilter(FilterComparisonType comparisonType, string leftExprColumnPath, AggregationTypeStrlict leftExprAggregationType, DateTime rightExprParameterValue)
EntitySchemaQueryFilter CreateFilter(FilterComparisonType comparisonType, string leftExprColumnPath, AggregationTypeStrict leftExprAggregationType, string rightExprParameterValue)
EntitySchemaQueryFilter CreateFilter(FilterComparisonType comparisonType, string leftExprColumnPath, AggregationTypeStrict leftExprAggregationType, object rightExprParameterValue, out EntitySchemaQuery leftExprSubQuery)
IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, string leftExprColumnPath, AggregationTypeStrict leftExprAggregationType, EntitySchemaQueryMacrosType macrosType, int daysCount)
IEntitySchemaQueryFilterItem CreateFilter(FilterComparisonType comparisonType, string leftExprColumnPath, AggregationTypeStrict leftExprAggregationType, EntitySchemaQueryMacrosType macrosType, out EntitySchemaQuery leftExprSubQuery, int daysCount)

Creates a query filter for selecting records according to specified conditions.

Parameters
comparisonType comparison type from the Terrasoft.Core.Entities.FilterComparisonType enumeration
leftExpressionColumnPath path to the column that contains the left side expression of the filter
leftExpression expression on the left side of the filter
leftExprAggregationType the type of aggregating function
leftExprSubQuery parameter that returns a subquery for the left side expression of the filter (if it is not equal to null) or a subquery for the first expression on the right side of the filter (if the left-side expression of the filter is equal to null)
rightExpressionColumnPaths array of column paths that contain the right side expressions of the filter
rightExpression expression on the right side of the filter;
rightExpressionValue instance of the expression function on the right side of the filter (the EntitySchemaQueryFunction parameter type) or a subquery expression on the right side of the filter (the EntitySchemaQuery parameter type)
rightValue value processed by the macro in the right side of the filter
rightExprParameterValue parameter value, to which the aggregate function on the right side of the filter is applied
macrosType a type of macro from the Terrasoft.Core.Entities.EntitySchemaQueryMacrosType enumeration
daysCount value to which the macro from the right side of the filter is applied. Optional parameter, default value is 0
IEntitySchemaQueryFilterItem CreateFilterWithParameters(FilterComparisonType comparisonType, bool useDisplayValue, string leftExpressionColumnPath, params object[] rightExpressionParameterValues)
IEntitySchemaQueryFilterItem CreateFilterWithParameters(FilterComparisonType comparisonType, string leftExpressionColumnPath, params object[] rightExpressionParameterValues)
IEntitySchemaQueryFilterItem CreateFilterWithParameters(FilterComparisonType comparisonType, string leftExpressionColumnPath, IEnumerable<object> rightExpressionParameterValues, bool useDisplayValue)
static IEntitySchemaQueryFilterItem CreateFilterWithParameters(EntitySchemaQuery parentQuery, EntitySchema rootSchema, FilterComparisonType comparisonType, bool useDisplayValue, string leftExpressionColumnPath, params object[] rightExpressionParameterValues)
static IEntitySchemaQueryFilterItem CreateFilterWithParameters(EntitySchema rootSchema, FilterComparisonType comparisonType, bool useDisplayValue, string leftExpressionColumnPath, params object[] rightExpressionParameterValues)

Creates a parameterized filter for selecting records matching certain conditions.

Parameters
parentQuery parent query for which the filter is being created
rootSchema the root schema
comparisonType comparison type from the Terrasoft.Core.Entities.FilterComparisonType enumeration
useDisplayValue defines the column value type that is used in the filter: true for the displayed value false – for the stored value;
leftExpressionColumnPath path to the column that contains the left side expression of the filter
rightExpressionParameterValues collection of parameter expressions on the right side of the filter
IEntitySchemaQueryFilterItem CreateIsNotNullFilter(string leftExpressionColumnPath)

Creates the comparison filter of the Is not “null” in database type and, as the tested value, sets the column expression located at the path specified in the leftExpressionColumnPath parameter.

IEntitySchemaQueryFilterItem CreateIsNullFilter(string leftExpressionColumnPath)

Creates the comparison filter of the Is “null” in database type and, as the testing condition, sets the column expression located at the path specified in the leftExpressionColumnPath parameter.

EntitySchemaQueryFilter CreateNotExistsFilter(string rightExpressionColumnPath)

Creates the Does not exist by the specified condition type comparison filter and sets the column expression located at the rightExpressionColumnPath specified path as the tested value.

DataTable GetDataTable(UserConnection userConnection)

Returns the result of the current query execution to the object schema as a data table in memory using UserConnection.

static int GetDayOfWeekNumber(UserConnection userConnection, DayOfWeek dayOfWeek)

Returns the sequence number of the week day for the System.DayOfWeek entity taking into account local settings.

Entity GetEntity(UserConnection userConnection, object primaryColumnValue)

Returns an Entity instance by the primaryColumnValue primary key using UserConnection.

EntityCollection GetEntityCollection(UserConnection userConnection, EntitySchemaQueryOptions options)
EntityCollection GetEntityCollection(UserConnection userConnection)

Returns the Entity instance collection representing the results of executing the current query using UserConnection and the specified additional EntitySchemaQueryOptions query settings.

EntitySchema GetSchema()

Returns the EntitySchema entity schema instance of the current EntitySchemaQuery instance.

Select GetSelectQuery(UserConnection userConnection)Select GetSelectQuery(UserConnection userConnection, EntitySchemaQueryOptions options)

Returns a data selection query instance using UserConnection and the specified additional settings of the EntitySchemaQueryOptions query.

EntitySchemaQueryColumnCollection GetSummaryColumns()
EntitySchemaQueryColumnCollection GetSummaryColumns(IEnumerable<string> columnNames)

Returns the collection of expressions of the query columns for which total values are calculated.

Entity GetSummaryEntity(UserConnection userConnection, EntitySchemaQueryColumnCollection summaryColumns)
Entity GetSummaryEntity(UserConnection userConnection)
Entity GetSummaryEntity(UserConnection userConnection, IEnumerable<string> columnNames)
Entity GetSummaryEntity(UserConnection userConnection, params string[] columnNames)

Returns an Entity instance for the result returned by the total value selection query.

Parameters
userConnection system user connection
summaryColumns collection of the query columns, whose totals are selected
columnNames column name collection
Select GetSummarySelectQuery(UserConnection userConnection, EntitySchemaQueryColumnCollection summaryColumns)
Select GetSummarySelectQuery(UserConnection userConnection)
Select GetSummarySelectQuery(UserConnection userConnection, IEnumerable<string> columnNames)
Select GetSummarySelectQuery(UserConnection userConnection, params string[] columnNames)

Builds a query for the selection of total values for a specified column collection of the EntitySchemaQuery current instance.

Parameters
userConnection system user connection
summaryColumns collection of the query columns, whose totals are selected
columnNames column name collection
T GetTypedColumnValue(Entity entity, string columnName)

Returns the typed column value with columnName from the Entity passed instance.

void LoadDataTableData(UserConnection userConnection, DataTable dataTable)
void LoadDataTableData(UserConnection userConnection, DataTable dataTable, EntitySchemaQueryOptions options)

Loads the result of executing the current query to the entity schema into the System.Data.DataTable entity using UserConnection and the EntitySchemaQueryOptions specified additional query settings.

void RemoveColumn(string columnName)

Removes the columnName column from the current query column collection.

void ResetSchema()

Clears the schema of the EntitySchemaQuery current instance.

void ResetSelectQuery()

Clears the select query for the current entity schema query.

void SetLocalizationCultureId(System.Guid cultureId)

Sets the identifier of the local culture.

Entity class
Advanced

Namespace Terrasoft.Core.Entities.

The Terrasoft.Core.Entities.Entity class is designed to provide access to an object that represents a record in the database table.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the Entity class.

Constructors 

public Entity(UserConnection userConnection)

Creates a new Entity class instance for the set UserConnection.

public Entity(UserConnection userConnection, Guid schemaUId)

Creates a new Entity class instance for the set UserConnection and the schema set by the schemaUId identifier.

public Entity(Entity source)

Creates a class instance that is a clone of the instance passed as an argument.

Properties 

ChangeType EntityChangeType

The type of changing the entity status (added, modified, deleted, unchanged).

EntitySchemaManager EntitySchemaManager

An instance of the entity schema manager.

EntitySchemaManagerName string

Name of the entity schema manager.

HasColumnValues bool

Determines whether an object has at least one column.

HierarchyColumnValue Guid

Value of column of the parent record relationship for hierarchical objects.

InstanceUId Guid

Object instance identifier.

IsDeletedFromDB bool

Determines whether the object is deleted from the database.

IsInColumnValueChanged bool

Determines whether the handling of the ColumnValueChanged event is performed.

IsInColumnValueChanging bool

Determines whether the handling of the ColumnValueChanging event is performed.

IsInDefColumnValuesSet bool

Determines whether the handling of the DefColumnValuesSet event is performed.

IsInDeleted bool

Determines whether the handling of the Deleted event is performed.

IsInDeleting bool

Determines whether the handling of the Deleting event is performed.

IsInInserted bool

Determines whether the handling of the Inserted event is performed.

IsInInserting bool

Determines whether the handling of the Inserting event is performed.

IsInLoaded bool

Determines whether the handling of the Loaded event is performed.

IsInLoading bool

Determines whether the handling of the Loading event is performed.

IsInSaved bool

Determines whether the handling of the Saved event is performed.

IsInSaveError bool

Determines whether the handling of the SaveError event is performed.

IsInSaving bool

Determines whether the handling of the Saving event is performed.

IsInUpdated bool

Determines whether the handling of the Updated event is performed.

IsInUpdating bool

Determines whether the handling of the Updating event is performed.

IsInValidating bool

Determines whether the handling of the Validating event is performed.

IsSchemaInitialized bool

Determines whether the entity schema is initialized.

LicOperationPrefix string

The prefix of the operation that is being licensed.

LoadState EntityLoadState

State of the object loading.

PrimaryColumnValue Guid

Initial column identifier.

PrimaryDisplayColumnValue string

Initial column value for displaying.

Process Process

The embedded process of an object.

Schema EntitySchema

An instance of the entity schema.

SchemaName string

Object schema name.

StoringState StoringObjectState

Object status (modified, added, deleted, unchanged).

UseAdminRights bool

Determines whether permissions will be taken into account when inserting, updating, deleting and receiving data.

UseDefRights bool

Determines whether the default object permissions should be used.

UseLazyLoad bool

Determines whether to use the initial lazy loading of object data.

UserConnection UserConnection

User connection.

ValidationMessages EntityValidationMessageCollection

Collection of the messages output when validating an object.

ValueListSchemaManager ValueListSchemaManager

An instance of the object enumerations manager.

ValueListSchemaManagerName string

Name of the manager for object enumerations.

Methods 

void AddDefRights()void AddDefRights(Guid primaryColumnValue)
void AddDefRights(IEnumerable<Guid> primaryColumnValues)

Sets the default permissions for the given object.

virtual object Clone()

Creates a clone of the current Entity instance.

Insert CreateInsert(bool skipLookupColumnValues)

Creates a query to insert data.

Update CreateUpdate(bool skipLookupColumnValues)

Creates a query to update data.

virtual bool Delete()
virtual bool Delete(object keyValue)

Deletes the object record from the database. The keyValue parameter determines the initial key of a record.

bool DeleteWithCancelProcess()

Deletes the object record from the database and cancels the launched process.

static Entity DeserializeFromJson(UserConnection userConnection, string jsonValue)

Creates an Entity type object using userConnection and populates the field values from the specified string of the JSON jsonValue format.

bool ExistInDB(EntitySchemaColumn conditionColumn, object conditionValue)
bool ExistInDB(string conditionColumnName, object conditionValue)
bool ExistInDB(object keyValue)
bool ExistInDB(Dictionary<string,object> conditions)

Determines whether a record matching the given condition of the conditionValue query to the conditionColumn object schema column or with the specified keyValue initial key exists in the database.

bool FetchFromDB(EntitySchemaColumn conditionColumn, object conditionValue, bool useDisplayValues)
bool FetchFromDB(string conditionColumnName, object conditionValue, bool useDisplayValues)
bool FetchFromDB(object keyValue, bool useDisplayValues)
bool FetchFromDB(Dictionary<string,object> conditions, bool useDisplayValues)
bool FetchFromDB(EntitySchemaColumn conditionColumn, object conditionValue, IEnumerable<EntitySchemaColumn> columnsToFetch, bool useDisplayValues)
bool FetchFromDB(string conditionColumnName, object conditionValue, IEnumerable<string>columnNamesToFetch, bool useDisplayValues)

By the specified condition, loads the object from the database.

Parameters
conditionColumn the column, for which the selection condition is specified
conditionColumnName the name of the column, for which the selection condition is specified
conditionValue the value of the condition column for the selected data
columnsToFetch the list of columns to be selected
columnNamesToFetch the list of column names to be selected
conditions set of conditions for filtering the selection of object records
keyValue the key field value
useDisplayValues indicates that the query returns the primary display values. If the parameter is true, the query will return the primary display values
bool FetchPrimaryColumnFromDB(object keyValue)

By the set condition, keyValue loads the object with the initial column from the database.

bool FetchPrimaryInfoFromDB(EntitySchemaColumn conditionColumn, object conditionValue)
bool FetchPrimaryInfoFromDB(string conditionColumnName, object conditionValue)

By the set condition, loads an object with initial columns including the initial display column from the database.

byte[] GetBytesValue(string valueName)

Returns the value of the specified object column as a byte array.

IEnumerable<EntityColumnValue> GetChangedColumnValues()

Returns the name collection of the object properties that have been modified.

string GetColumnDisplayValue(EntitySchemaColumn column)

Returns the value for display of the object property that matches the specified column of the entity schema.

object GetColumnOldValue(string valueName)
object GetColumnOldValue(EntitySchemaColumn column)

Returns the previous value of the specified object property.

virtual object GetColumnValue(string valueName)
virtual object GetColumnValue(EntitySchemaColumn column)

Returns the value of the object column with the specified name that matches the passed column of the object schema.

IEnumerable<string> GetColumnValueNames()

Returns the collection of object column names.

virtual bool GetIsColumnValueLoaded(string valueName)
bool GetIsColumnValueLoaded(EntitySchemaColumn column)

Returns whether the specified property of an object is loaded.

virtual MemoryStream GetStreamValue(string valueName)

Returns the value of the passed object schema column converted into the System.IO.MemoryStream type instance.

virtual TResult GetTypedColumnValue<TResult>(string valueName)
TResult GetTypedColumnValue<TResult>(EntitySchemaColumn column)

Returns the typed value of the object property that matches the specified column of the entity schema.

TResult GetTypedOldColumnValue<TResult>(string valueName)
TResult GetTypedOldColumnValue<TResult>(EntitySchemaColumn column)

Returns the typed previous value of the entity property that matches the specified column of the entity schema.

virtual bool InsertToDB(bool skipLookupColumnValues, bool validateRequired)

Adds an entry of the current object to the database taking into account the passed parameters:

Parameters
skipLookupColumnValues parameter that determines whether the columns of the lookup type are to be added to the database. If the parameter is true, the columns of the lookup type will not be added to the base. Default value – false
validateRequired parameter that determines the necessity of validating the required values. Default value – true
bool IsColumnValueLoaded(string valueName)
bool IsColumnValueLoaded(EntitySchemaColumn column)

Determines whether the value of the object property with the specified name is loaded.

virtual bool Load(DataRow dataRow)
virtual bool Load(DataRow dataRow, Dictionary<string,string> columnMap)
virtual bool Load(IDataReader dataReader)
virtual bool Load(IDataReader dataReader, IDictionary<string,string> columnMap)
virtual bool Load(object dataSource)
virtual bool Load(object dataSource, IDictionary<string,string> columnMap)

Populates the object with the passed data.

Parameters
dataRow the System.Data.DataRow instance from which the data is loaded to the object
dataReader the System.Data.IDataReader instance from which the data is loaded to the object
dataSource the System.Object instance from which the data is loaded to the object
columnMap object properties populated with data
void LoadColumnValue(string columnValueName, IDataReader dataReader, int fieldIndex, int binaryPackageSize)
void LoadColumnValue(string columnValueName, IDataReader dataReader, int fieldIndex)
void LoadColumnValue(string columnValueName, object value)
void LoadColumnValue(EntitySchemaColumn column, object value)

Loads the value from the passed instance for the property with the specified name.

Parameters
columnValueName name of the object property
column object schema column
dataReader the System.Data.IDataReader instance from which the property value is loaded
fieldIndex index of the field loaded from System.Data.IDataReader
binaryPackageSize size of the loaded value
value value of the property that is being loaded
static Entity Read(UserConnection userConnection, DataReader dataReader)

Returns the current property value of the Entity type from the output stream.

void ReadData(DataReader reader)
void ReadData(DataReader reader, EntitySchema schema)

Reads data from the object schema and saves them in the specified object of the System.Data.IDataReader type.

void ResetColumnValues()

Cancels changes for all object properties.

void ResetOldColumnValues()

Reverts all object properties to previous values.

bool Save(bool validateRequired)

Saves the object to the database. The validateRequired parameter determines the necessity of validating the required values. Default value – true.

static string SerializeToJson(Entity entity)

Converts the entity object into a JSON format string.

virtual void SetBytesValue(string valueName, byte[] streamBytes)

Sets the passed value of the System.Byte type for the specified object property.

bool SetColumnBothValues(EntitySchemaColumn column, object value, string displayValue)
bool SetColumnBothValues(string columnValueName, object value, string displayColumnValueName, string displayValue)

Sets the passed value and displayValue to the object property matching the specified schema column.

bool SetColumnValue(string valueName, object value)
bool SetColumnValue(EntitySchemaColumn column, object value)

Sets the passed value to the specified schema column.

void SetDefColumnValue(string columnValueName, object defValue)
void SetDefColumnValue(string columnValueName)

Sets the property with the specified name to the default value.

void SetDefColumnValues()

Sets default values for all object properties.

bool SetStreamValue(string valueName, Stream value)

Sets the passed value of the System.IO.Stream type for the specified object property.

virtual bool UpdateInDB(bool validateRequired)

Updates the object record in the database. The validateRequired parameter determines the necessity of validating the required values. Default value – true.

bool Validate()

Verifies if the required fields are populated.

static void Write(DataWriter dataWriter, Entity entity, string propertyName)
static void Write(DataWriter dataWriter, Entity entity, string propertyName, bool couldConvertForXml)

Records the value of the Entity type to the output stream with the specified name.

Parameters
dataWriter instance of the Terrasoft.Common.DataWriter class that provides methods for sequential recording of values to the output stream
entity value for record of the Entity type
propertyName name of the object
couldConvertForXml allows converting for XML-serialization
void Write(DataWriter dataWriter, string propertyName)

Records the value of the Entity type to the output stream with the specified name.

void WriteData(DataWriter writer)
void WriteData(DataWriter writer, EntitySchema schema)

Records to the output stream for the specified object schema.

Events 

event EventHandler<EntityColumnAfterEventArgs> ColumnValueChanged

Event handler used after modifying the value of an entity column.

The event handler receives an argument of the EntityColumnAfterEventArgs type.

The EntityColumnAfterEventArgs properties that provide information referring to the event:

  • ColumnValueName;
  • DisplayColumnValueName.
event EventHandler<EntityColumnBeforeEventArgs> ColumnValueChanging

Event handler used before modifying the value of an entity column.

The event handler receives an argument of the EntityColumnBeforeEventArgs type.

The EntityColumnBeforeEventArgs properties that provide information referring to the event:

  • ColumnStreamValue;
  • ColumnValue<;/li>
  • ColumnValueName;
  • DisplayColumnValue;
  • DisplayColumnValueName.
event EventHandler<EventArgs> DefColumnValuesSet

Event handler used after setting default values for the object fields.

event EventHandler<EntityAfterEventArgs> Deleted

Event handler used after deleting an object.

The event handler receives an argument of the EntityAfterEventArgs type.

The EntityAfterEventArgs properties that provide information referring to the event:

  • ModifiedColumnValues;
  • PrimaryColumnValue.
event EventHandler<EntityBeforeEventArgs> Deleting

Event handler used before deleting an object.

The event handler receives an argument of the EntityBeforeEventArgs type.

The EntityBeforeEventArgs properties that provide information referring to the event:

  • AdditionalCondition;
  • IsCanceled;
  • KeyValue.
event EventHandler<EntityAfterEventArgs> Inserted

Event handler used after inserting an object.

The event handler receives an argument of the EntityAfterEventArgs type.

The EntityAfterEventArgs properties that provide information referring to the event:

  • ModifiedColumnValues;
  • PrimaryColumnValue.
event EventHandler<EntityBeforeEventArgs> Inserting

Event handler used before inserting an object.

The event handler receives an argument of the EntityBeforeEventArgs type.

The EntityBeforeEventArgs properties that provide information referring to the event:

  • AdditionalCondition;
  • IsCanceled;
  • KeyValue.
event EventHandler<EntityAfterLoadEventArgs> Loaded

Event handler used after loading an object.

The event handler receives an argument of the EntityAfterLoadEventArgs type.

The EntityAfterLoadEventArgs properties that provide information referring to the event:

  • ColumnMap;
  • DataSource.
event EventHandler<EntityBeforeLoadEventArgs> Loading

Event handler used before loading an object.

The event handler receives an argument of the EntityBeforeLoadEventArgs type.

The EntityBeforeLoadEventArgs properties that provide information referring to the event:

  • ColumnMap;
  • DataSource;
  • IsCanceled.
event EventHandler<EntityAfterEventArgs> Saved

Event handler used after saving an object.

The event handler receives an argument of the EntityAfterEventArgs type.

The EntityAfterEventArgs properties that provide information referring to the event:

  • ModifiedColumnValues;
  • PrimaryColumnValue.
event EventHandler<EntitySaveErrorEventArgs> SaveError

Event handler used when an error occurs while saving an object.

The event handler receives an argument of the EntitySaveErrorEventArgs type.

The EntitySaveErrorEventArgs properties that provide information referring to the event:

  • Exception;
  • IsHandled.
event EventHandler<EntityBeforeEventArgs> Saving

Event handler used before saving an object.

The event handler receives an argument of the EntityBeforeEventArgs type.

The EntityBeforeEventArgs properties that provide information referring to the event:

  • AdditionalCondition;
  • IsCanceled;
  • KeyValue.
event EventHandler<EntityAfterEventArgs> Updated

Event handler used after updating an object.

The event handler receives an argument of the EntityAfterEventArgs type.

The EntityAfterEventArgs properties that provide information referring to the event:

  • ModifiedColumnValues;
  • PrimaryColumnValue.
event EventHandler<EntityBeforeEventArgs>Updating

Event handler used before updating an object.

The event handler receives an argument of the EntityBeforeEventArgs type.

The EntityBeforeEventArgs properties that provide information referring to the event:

  • AdditionalCondition;
  • IsCanceled;
  • KeyValue.
event EventHandler<EntityValidationEventArgs> Validating

Event handler used when validating an object.

The event handler receives an argument of the EntityValidationEventArgs type.

The EntityValidationEventArgs properties that provide information referring to the event:

  • Messages.
EntityMapper class
Advanced

The Terrasoft.Configuration.EntityMapper class is a utility configuration class that stored in the FinAppLending package of the Lending product. EntittyMapper allows to map data of one Entity with another using rules defined in the configuration file. Using the approach of mapping the data of different entities avoids the appearance of a monotonous code.

The idea of mapping the data of different entities is implemented in the following classes:

  • EntityMapper – implements the mapping logic.
  • EntityResult – defines the resulting type of the mapped entity.
  • MapConfig – a set of mapping rules.
  • DetailMapConfig – used to set up a list of mapping rules of the details and entities connected with them.
  • RelationEntityMapConfig – contains rules for mapping connected entities.
  • EntityFilterMap – a filter for database query.

The EntityMapper class 

The Namespace Terrasoft.Configuration.

Class implements the mapping logic.

Methods 

virtual EntityResult GetMappedEntity(Guid recId, MapConfig config)

Returns mapped data for two Entity objects.

Parameters
recId GUID records in the database
config an instance of the MapConfig class, which is a set of mapping rules
virtual Dictionary<string, object> GetColumnsValues(Guid recordId, MapConfig config, Dictionary<string, object> result)

Gets the main entity from the database and matches its columns and values according to the rules specified in the config object.

Parameters
recordId GUIDrecodr in the database
config an instance of the MapConfig class, which is a set of mapping rules
result a dictionary of columns and their values of the mapped entity
virtual Dictionary<string, object> GetRelationEntityColumnsValues(List<RelationEntityMapConfig> relations, Dictionary<string, object> dictionaryToMerge, string columnName, Terrasoft.Nui.ServiceModel.DataContract.LookupColumnValue entitylookup)

Gets the related entities from the database and matches them to the main entities.

Parameters
relations a list of rules for obtaining related records
dictionaryToMerge a dictionary with columns and theirs values
columnName name of the parent column
entitylookup an object that contains name and Id of the record in the database

The EntityResult class 

The Namespace Terrasoft.Configuration.

Class defines the resulting type of the mapped entity.

Properties 

Columns Dictionary<string, object>

A dictionary of main entity column names and their values.

Details Dictionary<string, List<Dictionary<string, object>>>

A dictionary of the detail names with the list of their columns and values.

The MapConfig class 

The Namespace Terrasoft.Configuration.

Class sets of mapping rules.

Properties 

SourceEntityName string

Entity name in the database.

Columns Dictionary<string, object>

A dictionary with the names of columns of one entity and compared columns of another entity.

DetailsConfig List<DetailMapConfig>

A list of configuration objects with rules for details.

CleanDetails List<string>

A list of detail names for cleaning their values.

RelationEntities List<RelationEntityMapConfig>

List of configuration objects with rules for mapping related records with the main entity.

The DetailMapConfig class 

The Namespace Terrasoft.Configuration.

Class used to set up a list of mapping rules of the details and entities connected with them.

Properties 

DetailName string

Detail name (The ensure the uniqueness of detail instance).

SourceEntityName string

Entity name in the database.

Columns Dictionary<string, object>

A dictionary with the names of columns of one entity and compared columns of another entity.

Filters List<EntityFilterMap>

A list of configuration objects with filtration rules for more accurate selections from the database.

RelationEntities List<RelationEntityMapConfig>

List of configuration objects with rules for mapping related records with the main entity.

The RelationEntityMapConfig class 

The Namespace Terrasoft.Configuration.

Class contains rules for mapping connected entities.

Properties 

ParentColumnName string

The name of the parent column, which, when found, will trigger the logic for obtaining and mapping the entity data.

SourceEntityName string

Entity name in the database.

Columns Dictionary<string, object>

A dictionary with the names of columns of one entity and compared columns of another entity.

Filters List<EntityFilterMap>

A list of configuration objects with filtration rules to refine selections from the database.

RelationEntities List<RelationEntityMapConfig>

List of configuration objects with rules for mapping related records with the main entity.

The EntityFilterMap class 

The Namespace Terrasoft.Configuration.

Class filters for database query.

Properties 

ColumnName string

The name of the column, which when found, will start the filtering logic.

Value object

The value to compare to.

EntitySchemaQueryFunction class
Advanced

The Terrasoft.Core.Entities.EntitySchemaQueryFunction class implements the expression function.

The expression function is implemented in the following classes:

  • EntitySchemaQueryFunction – the base class of expression of the entity schema query.
  • EntitySchemaAggregationQueryFunction – implements the aggregate function of the expression.
  • EntitySchemaIsNullQueryFunction – replaces null values with the replacement expression.
  • EntitySchemaCoalesceQueryFunction – returns the first not null expression from the list of arguments.
  • EntitySchemaCaseNotNullQueryFunctionWhenItem – class that describes the condition expression of the CASE SQL operator.
  • EntitySchemaCaseNotNullQueryFunctionWhenItems – collection of condition expressions of the CASE SQL operator.
  • EntitySchemaCaseNotNullQueryFunction – returns one value from the set of possible values depending on the specified conditions.
  • EntitySchemaSystemValueQueryFunction – returns the expression of the system value.
  • EntitySchemaCurrentDateTimeQueryFunction – implements the function for current date and time expression.
  • EntitySchemaBaseCurrentDateQueryFunction – base class of the expression function for the base date.
  • EntitySchemaCurrentDateQueryFunction – implements the function for current date and time expression.
  • EntitySchemaDateToCurrentYearQueryFunction – implements the function that converts the date expression to the same date of the current year.
  • EntitySchemaBaseCurrentDateTimeQueryFunction – implements the function for current date and time expression.
  • EntitySchemaDatePartQueryFunction – implements the function for the datepart of the Date/Time type.
  • EntitySchemaCastQueryFunction – casts the argument expression to the specified data type.
  • EntitySchemaUpperQueryFunction – converts the argument expression characters to uppercase.
  • EntitySchemaTrimQueryFunction – removes whitespaces from both ends of the expression.
  • EntitySchemaLengthQueryFunction – returns the length of the expression.
  • EntitySchemaConcatQueryFunction – returns a string resulting from merging the string arguments of the function.
  • EntitySchemaWindowQueryFunction – implements an SQL window function.

The EntitySchemaQueryFunction class 

Namespace Terrasoft.Core.Entities

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, parent classes, and implemented interfaces of the EntitySchemaQueryFunction class.

Methods 

abstract QueryColumnExpression CreateQueryColumnExpression(DBSecurityEngine dbSecurityEngine)

For the current function, gets the query column expression that is generated taking into account the specified access rights.

Parameters
dbSecurityEngine a Terrasoft.Core.DB.DBSecurityEngine object that defines access rights
abstract DataValueType GetResultDataValueType(DataValueTypeManager dataValueTypeManager)

Gets the data type of the output returned by the function, using the passed-in data type manager.

Parameters
dataValueTypeManager data type manager
abstract bool GetIsSupportepataValueType(DataValueType dataValueType)

Indicates whether the output of the function has the specified data type.

Parameters
dataValueType the type of data
abstract string GetCaption()

Gets the caption of the expression function.

virtual EntitySchemaQueryExpressionCollection GetArguments()

Gets the collection of expressions of function arguments.

void CheckIsSupportepataValueType(DataValueType dataValueType)

Verifies that the output of the function has the specified data type. Otherwise, an exception is thrown.

Parameters
dataValueType the type of data

The EntitySchemaAggregationQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaAggregationQueryFunction class.

Constructors 

EntitySchemaAggregationQueryFunction(EntitySchemaQuery parentQuery)

Initializes the EntitySchemaAggregationQueryFunction instance of the specified aggregate function type for the specified query to the object schema.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaAggregationQueryFunction(AggregationTypeStrict aggregationType, EntitySchemaQuery parentQuery)

Initializes the EntitySchemaAggregationQueryFunction instance of the specified aggregate function type for the specified query to the object schema.

Parameters
aggregationType the type of aggregating function
parentQuery query against the schema of the entity that contains the function
EntitySchemaAggregationQueryFunction(AggregationTypeStrict aggregationType, EntitySchemaQueryExpression expression, EntitySchemaQuery parentQuery)

Initializes a new EntitySchemaAggregationQueryFunction instance for the specified type of aggregate function, expression, and query to the object schema.

Parameters
aggregationType the type of aggregating function
expression a query expression
parentQuery query against the schema of the entity that contains the function
EntitySchemaAggregationQueryFunction(EntitySchemaAggregationQueryFunction source)

Initializes a new EntitySchemaAggregationQueryFunction instance that is a clone of the passed aggregate expression function instance.

Parameters
source instance of the expression aggregate function whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

AggregationType AggregationTypeStrict

The type of aggregating function.

AggregationEvalType AggregationEvalType

The scope of the aggregate function.

Expression EntitySchemaQueryExpression

The expression of the aggregate function argument.

Methods 

override void WriteMetaData(DataWriter writer)

Serializes the aggregate function, using the specified Terrasoft.Common.DataWriter instance.

Parameters
writer the Terrasoft.Common.DataWriter instance used for serialization
override QueryColumnExpression CreateQueryColumnExpression(DBSecurityEngine dbSecurityEngine)

For the aggregate function, gets the query column expression that is generated taking into account the specified access rights.

Parameters
dbSecurityEngine a Terrasoft.Core.DB.DBSecurityEngine object that defines access rights
override EntitySchemaQueryExpressionCollection GetArguments()

Gets the collection of expressions of the aggregate function arguments.

override DataValueType GetResultDataValueType(DataValueTypeManager dataValueTypeManager)

Gets the data type of the output returned by the aggregate function, using the specified data type manager.

Parameters
dataValueTypeManager data type manager
override bool GetIsSupportepataValueType(DataValueType dataValueType)

Indicates whether the output of the aggregate function has the specified data type.

Parameters
dataValueType the type of data
override string GetCaption()

Gets the caption of the expression function.

override object Clone()

Creates a clone of the current EntitySchemaAggregationQueryFunction instance.

EntitySchemaAggregationQueryFunction All()

Sets the To All Values scope for the current aggregate function.

EntitySchemaAggregationQueryFunction Distinct()

Sets the To Unique Values scope for the current aggregate function.

The EntitySchemaIsNullQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaIsNullQueryFunction class.

Constructors 

EntitySchemaIsNullQueryFunction(EntitySchemaQuery parentQuery)

Initializes the EntitySchemaIsNullQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaIsNullQueryFunction(EntitySchemaQuery parentQuery, EntitySchemaQueryExpression checkExpression, EntitySchemaQueryExpression replacementExpression)

Initializes a new EntitySchemaIsNullQueryFunction instance for the specified query to the object schema, validated expression and substitute expression.

Parameters
parentQuery query against the schema of the entity that contains the function
checkExpression the expression to check for being null
replacementExpression the expression returned by the function if checkExpression is null
EntitySchemaIsNullQueryFunction(EntitySchemaIsNullQueryFunction source)

Initializes a new EntitySchemaIsNullQueryFunction instance that is a clone of the passed expression function.

Parameters
source an instance of the EntitySchemaIsNullQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

CheckExpression EntitySchemaQueryExpression

Expression of the function argument to check for being equal to the null value.

ReplacementExpression EntitySchemaQueryExpression

Expression of the function argument that is returned if the check expression is equal to null.

Methods 

override void WriteMetaData(DataWriter writer)

Serializes the expression function, using the passed DataWriter instance.

Parameters
writer the DataWriter instance used for serializing the expression function
override QueryColumnExpression CreateQueryColumnExpression(DBSecurityEngine dbSecurityEngine)

For the current function, gets the query column expression that is generated taking into account the specified access rights.

Parameters
dbSecurityEngine a Terrasoft.Core.DB.DBSecurityEngine object that defines the access rights
override EntitySchemaQueryExpressionCollection GetArguments()

Gets the collection of expressions of function arguments.

override DataValueType GetResultDataValueType(DataValueTypeManager dataValueTypeManager)

Gets the data type of the output returned by the function, using the passed-in data type manager.

Parameters
dataValueTypeManager data type manager

The EntitySchemaCoalesceQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaCoalesceQueryFunction class.

Constructors 

EntitySchemaCoalesceQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaCoalesceQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaCoalesceQueryFunction(EntitySchemaCoalesceQueryFunction source)

Initializes a new EntitySchemaCoalesceQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaCoalesceQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

Expressions EntitySchemaQueryExpressionCollection

Collection of expressions of function arguments.

HasExpressions bool

Indicates whether at least one item exists in the collection of expressions of the function arguments.

Methods 

override bool GetIsSupportepataValueType(DataValueType dataValueType)

Indicates whether the output of the function has the specified data type.

Parameters
dataValueType the type of data

The EntitySchemaCaseNotNullQueryFunctionWhenItem class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, parent classes, and implemented interfaces of the EntitySchemaCaseNotNullQueryFunctionWhenItem class.

Constructors 

EntitySchemaCaseNotNullQueryFunctionWhenItem()

Initializes a new instance of the EntitySchemaCaseNotNullQueryFunctionWhenItem class.

EntitySchemaCaseNotNullQueryFunctionWhenItem(EntitySchemaQueryExpression whenExpression, EntitySchemaQueryExpression thenExpression)

Initializes the EntitySchemaCaseNotNullQueryFunctionWhenItem instance for the specified expressions of the WHEN and THEN clauses.

Parameters
whenExpression expression of the WHEN condition clause
thenExpression expression of the THEN condition clause
EntitySchemaCaseNotNullQueryFunctionWhenItem(EntitySchemaCaseNotNullQueryFunctionWhenItem source)

Initializes the EntitySchemaCaseNotNullQueryFunctionWhenItem instance that is a clone of the passed function.

Parameters
source the EntitySchemaCaseNotNullQueryFunctionWhenItem whose clone is being created

Properties 

WhenExpression EntitySchemaQueryExpression

Expression of the WHEN clause.

ThenExpression EntitySchemaQueryExpression

Expression of the THEN clause.

The EntitySchemaCaseNotNullQueryFunctionWhenItems class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, parent classes, and implemented interfaces of the EntitySchemaCaseNotNullQueryFunctionWhenItems class.

Constructors 

EntitySchemaCaseNotNullQueryFunctionWhenItems()

Initializes an EntitySchemaCaseNotNullQueryFunctionWhenItems instance.

EntitySchemaCaseNotNullQueryFunctionWhenItems(EntitySchemaCaseNotNullQueryFunctionWhenItems source)

Initializes a new EntitySchemaCaseNotNullQueryFunctionWhenItems instance that is a clone of the passed collection of conditions.

Parameters
source the collection of conditions whose clone is being created

The EntitySchemaCaseNotNullQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaCaseNotNullQueryFunction class.

Constructors 

EntitySchemaCaseNotNullQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaCaseNotNullQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaCaseNotNullQueryFunction(EntitySchemaCaseNotNullQueryFunction source)

Initializes a new EntitySchemaCaseNotNullQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaCaseNotNullQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

WhenItems EntitySchemaCaseNotNullQueryFunctionWhenItems

Collection of conditions of the expression function.

HasWhenItems bool

Indicates whether the function has at least one condition.

ElseExpression EntitySchemaQueryExpression

Expression of the ELSE clause.

Methods 

void SpecifyQueryAlias(string queryAlias)

For the current expression function, defines the specified alias in the resulting SQL query.

Parameters
queryAlias alias to define for the current function

The EntitySchemaSystemValueQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaSystemValueQueryFunction class.

Properties 

QueryAlias string

The alias of the function in the SQL query.

SystemValueName string

Name of the system value.

The EntitySchemaBaseCurrentDateQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaBaseCurrentDateQueryFunction class.

Properties 

SystemValueName string

Name of the system value.

Offset int

The offset.

The EntitySchemaDateToCurrentYearQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaDateToCurrentYearQueryFunction class.

Constructors 

EntitySchemaDateToCurrentYearQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaDateToCurrentYearQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaDateToCurrentYearQueryFunction(EntitySchemaQuery parentQuery, EntitySchemaQueryExpression expression)

Initializes the new EntitySchemaDateToCurrentYearQueryFunction instance for the specified entity schema query and passed date expression.

Parameters
parentQuery query against the schema of the entity that contains the function
expression a query expression
EntitySchemaDateToCurrentYearQueryFunction(EntitySchemaDateToCurrentYearQueryFunction source)

Initializes a new EntitySchemaDateToCurrentYearQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaDateToCurrentYearQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

Expression EntitySchemaQueryExpression

The expression of the function arguments.

The EntitySchemaCurrentTimeQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaCurrentTimeQueryFunction class.

Constructors 

EntitySchemaCurrentTimeQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaCurrentTimeQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaCurrentTimeQueryFunction(EntitySchemaCurrentTimeQueryFunction source)

Initializes a new EntitySchemaCurrentTimeQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaCurrentTimeQueryFunction whose clone is being created

Properties 

SystemValueName string

Name of the system value.

The EntitySchemaCurrentUserQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaCurrentUserQueryFunction class.

Constructors 

EntitySchemaCurrentUserQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaCurrentUserQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaCurrentUserQueryFunction(EntitySchemaCurrentUserQueryFunction source)

Initializes a new EntitySchemaCurrentUserQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaCurrentUserQueryFunction whose clone is being created

Properties 

SystemValueName string

Name of the system value.

The EntitySchemaCurrentUserAccountQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaCurrentUserAccountQueryFunction class.

Constructors 

EntitySchemaCurrentUserAccountQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaCurrentUserAccountQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaCurrentUserAccountQueryFunction(EntitySchemaCurrentUserAccountQueryFunction source))

Initializes a new EntitySchemaCurrentUserAccountQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaCurrentUserAccountQueryFunction whose clone is being created

Properties 

SystemValueName string

Name of the system value.

The EntitySchemaUpperQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaUpperQueryFunction class.

Constructors 

EntitySchemaUpperQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaUpperQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaUpperQueryFunction(EntitySchemaQuery parentQuery, EntitySchemaQueryExpression expression)

Initializes the new EntitySchemaUpperQueryFunction instance for the specified entity schema query and passed date expression.

Parameters
parentQuery query against the schema of the entity that contains the function
expression a query expression
EntitySchemaUpperQueryFunction(EntitySchemaUpperQueryFunction source)

Initializes a new EntitySchemaUpperQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaUpperQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

Expression EntitySchemaQueryExpression

The expression of the function arguments.

The EntitySchemaTrimQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaTrimQueryFunction class.

Constructors 

EntitySchemaTrimQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaTrimQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaTrimQueryFunction(EntitySchemaQuery parentQuery, EntitySchemaQueryExpression expression)

Initializes the new EntitySchemaTrimQueryFunction instance for the specified entity schema query and passed date expression.

Parameters
parentQuery query against the schema of the entity that contains the function
expression a query expression
EntitySchemaTrimQueryFunction(EntitySchemaTrimQueryFunction source)

Initializes a new EntitySchemaTrimQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaTrimQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

Expression EntitySchemaQueryExpression

The expression of the function arguments.

The EntitySchemaLengthQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaLengthQueryFunction class.

Constructors 

EntitySchemaLengthQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaLengthQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaLengthQueryFunction(EntitySchemaQuery parentQuery, EntitySchemaQueryExpression expression)

Initializes the new EntitySchemaLengthQueryFunction instance for the specified entity schema query and passed date expression.

Parameters
parentQuery query against the schema of the entity that contains the function
expression a query expression
EntitySchemaLengthQueryFunction(EntitySchemaLengthQueryFunction source)

Initializes a new EntitySchemaLengthQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaLengthQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

Expression EntitySchemaQueryExpression

The expression of the function arguments.

The EntitySchemaCastQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaCastQueryFunction class.

Constructors 

EntitySchemaCastQueryFunction(EntitySchemaQuery parentQuery, DBDataValueType castType)

Initializes a new EntitySchemaCastQueryFunction instance for the specified query to the schema of the object with the specified target data type.

Parameters
parentQuery query against the schema of the entity that contains the function
castType the target data type
EntitySchemaCastQueryFunction(EntitySchemaQuery parentQuery, EntitySchemaQueryExpression expression, DBDataValueType castType)

Initializes a new EntitySchemaCastQueryFunction instance with the specified expression and target data type.

Parameters
parentQuery query against the schema of the entity that contains the function
expression a query expression
castType the target data type
EntitySchemaCastQueryFunction(EntitySchemaCastQueryFunction source)

Initializes a new EntitySchemaCastQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaCastQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

Expression EntitySchemaQueryExpression

The expression of the function argument.

CastType DBDataValueType

The target data type.

The EntitySchemaConcatQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaConcatQueryFunction class.

Constructors 

EntitySchemaConcatQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaConcatQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaConcatQueryFunction(EntitySchemaQuery parentQuery, EntitySchemaQueryExpression[] expressions)

Initializes a new EntitySchemaConcatQueryFunction instance for the specified array of expressions and entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
expressions array of expressions
EntitySchemaConcatQueryFunction(EntitySchemaConcatQueryFunction source)

Initializes a new EntitySchemaConcatQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaConcatQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

Expressions EntitySchemaQueryExpressionCollection

Collection of expressions of function arguments.

HasExpressions bool

Indicates whether at least one item exists in the collection of expressions of the function arguments.

The EntitySchemaWindowQueryFunction class 

Namespace Terrasoft.Core.Entities.

Note. Use the “.NET class libraries of platform core” documentation to access the full list of the methods, properties, parent classes, and implemented interfaces of the EntitySchemaWindowQueryFunction class.

Constructors 

EntitySchemaWindowQueryFunction(EntitySchemaQuery parentQuery)

Initializes the new EntitySchemaWindowQueryFunction instance for the specified entity schema query.

Parameters
parentQuery query against the schema of the entity that contains the function
EntitySchemaWindowQueryFunction(EntitySchemaQueryExpression function, EntitySchemaQuery esq)

Initializes the new EntitySchemaWindowQueryFunction instance for the specified entity schema query.

Parameters
function nested query function
esq the expression of the entity schema query
EntitySchemaWindowQueryFunction(EntitySchemaQueryExpression function, EntitySchemaQuery esq, EntitySchemaQueryExpression partitionBy = null, EntitySchemaQueryExpression orderBy = null)

Initializes the new EntitySchemaWindowQueryFunction instance for the specified entity schema query.

Parameters
function nested query function
parentQuery query against the schema of the entity that contains the function
partitionBy the expression for splitting the query
orderBy the expression for sorting the query
EntitySchemaWindowQueryFunction(EntitySchemaQueryFunction source)

Initializes a new EntitySchemaWindowQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaQueryFunction whose clone is being created
EntitySchemaWindowQueryFunction(EntitySchemaWindowQueryFunction source)

Initializes a new EntitySchemaWindowQueryFunction instance that is a clone of the passed function.

Parameters
source the EntitySchemaWindowQueryFunction whose clone is being created

Properties 

QueryAlias string

The alias of the function in the SQL query.

InnerFunction EntitySchemaQueryExpression

The function to apply.

PartitionByExpression EntitySchemaQueryExpression

Split by expression.

OrderByExpression EntitySchemaQueryExpression

Sort by expression.