examples of the use VariableDef and DetailVariableDef

When constructing constraints using the method GetFunction argument to this method depending on the type of applied functions may be passed a description of the variable:

  • when setting limits with SQLWhereLanguageDef class is used VariableDef,
  • when imposing restrictions on detail with ExternalLangDef to describe the variable-detail used class DetailVariableDef.

VariableDef

Class VariableDef is used to define the variable in the restriction (usually indicates an attribute object). Used together with SQLWhereLanguageDef.

Defined in namespace: ICSSoft.STORMNET.FunctionalLanguage.

Build: ICSSoft.STORMNET.FunctionalLanguage.dll.

The most common constructor that is used when building constraints:

public VariableDef(ObjectType objType, string objStringedView)

He is passed the parameters:

  • objType - ObjectType-the type of the variable (for example, langdef.StringType),
  • objStringedView - the property name of the object on which the plan limitation.

Examples of design VariableDef when specifying constraints, see SQLWhereLanguageDef.

VariableDef to PrimaryKey

When building restrictions on primary keys deducted objects (private keys) it is worth considering that SQLWhereLanguageDef ignores constant PrimaryKey. Instead of a constant PrimaryKey better to use StormMainObjectKey (determined by the corresponding constant).

Wrong:

var ld = SQLWhereLanguageDef.LanguageDef;
ld.GetFunction(ld.funcEQ, new VariableDef(ld.GuidType, "PrimaryKey"), "64F45BC3-339B-4FBA-A036-C5E9FE9EAE53");

True:

var ld = SQLWhereLanguageDef.LanguageDef;
ld.GetFunction(ld.funcEQ, new VariableDef(ld.GuidType, SQLWhereLanguageDef.StormMainObjectKey), "64F45BC3-339B-4FBA-A036-C5E9FE9EAE53");

It should be noted that the restriction on primary key masters is imposed as follows:

var ld = SQLWhereLanguageDef.LanguageDef;
ld.GetFunction(ld.funcEQ, new VariableDef(ld.GuidType, Information.ExtractPropertyPath<СамОбъект>(x => x.СсылкаНаМастера)), "84F456C1-312F-30C0-A238-11E3FE68E852");

where “Silentmaster” - a reference to the master.

DetailVariableDef

Class DetailVariableDef is used to determine the variable restrictions, to describe detailov. Used in conjunction with ExternalLangDef.

Defined in namespace: ICSSoft.STORMNET.Windows.Forms. Build: ExternalLangDef.dll.

When designing DetailVariableDef specify the settings:

  • Type - ObjectType-the type (you can get ldef.GetObjectType("Details")),
  • View - the view name of detail,
  • ConnectMasterProp - way from detail (see description below)
  • OwnerConnectProp - detalu from the object (see the description later).

Examples of design DetailVariableDef when setting restrictions is available in the article:

Job OwnerConnectProp and ConnectMasterProp

Problems often arise in determining what to specify as ConnectMasterProp and OwnerConnectProp.

ConnectMasterProp specifies the path from detail and OwnerConnectProp - detalu from the object.

The bundle is as follows: Detail.ConnectMasterProp = Object.OwnerConnectProp.

It is worth noting that the property OwnerConnectProp determines what objects are detaily. If the property is not specified (i.e., specified null), the conjunction occurs on the primary key(i.e. StormMainObjectKey).

Examples of usage

Example 1

It is necessary to filter Odottamattomasti for Salenatural. When setting DetailVariableDef should specify: OwnerConnectProp = Person, ConnectMasterProp = Identity.

Example 2

It is necessary to filter Obrazovatelnogo for Stroyrekonstruksiya. When setting DetailVariableDef should specify: OwnerConnectProp = Zaveniaghina.Personality ConnectMasterProp = Identity.

It is necessary to filter Obrazovatelnogo for Stroyrekonstruksiya. When setting DetailVariableDef should specify: OwnerConnectProp = Zaveniaghina.Personality ConnectMasterProp = Identity.

setting limits on pseudometal

For example, the entity “Customer” and “Credit” are connected shown in the image.

You need to restrict clients by setting the limit to reference them loans.

It is obvious that from the point of view of storage of this object model in the database in accordance with existing rules, there is no distinction between aggregation and simple Association. However, restricting the sample according to the criteria of the child table do not differ in the case of aggregation and Association. Therefore to build restrictions in the case of pseudometal you must use DetailVariableDef together with ExternalLangDef.

If in the above example, it is necessary to select customers that have loans for more than 15 years, the code will look as follows:

ExternalLangDef ldef = ExternalLangDef.LanguageDef;
LoadingCustomizationStruct lcsДолгосрочныеКлиенты = LoadingCustomizationStruct.GetSimpleStruct(typeof(Клиент), "Client");
lcsДолгосрочныеКлиенты.LoadingTypes = new[) { typeof(Клиент) };
var view = Information.GetView("Loan", typeof(Кредит));
var dvd = new DetailVariableDef
{
    ConnectMasterPorp = "Client",
    OwnerConnectProp = new[) { SQLWhereLanguageDef.StormMainObjectKey },
    View = view,
    Type = ldef.GetObjectType("Details")
};
lcsДолгосрочныеКлиенты.LimitFunction = ldef.GetFunction(ldef.funcExist, dvd,
                                                        ldef.GetFunction(ldef.funcGEQ, 
                                                        new VariableDef(ldef.GuidType, "Loanyears"), 15));
ICSSoft.STORMNET.DataObject[) dobjsДолгосрочныеКлиенты = DataServiceProvider.DataService.LoadObjects(lcsДолгосрочныеКлиенты);
Переведено сервисом «Яндекс.Переводчик» http://translate.yandex.ru