using calculated properties of objects
This example shows how to use calculated properties.
Example of defining a calculated property for the object Person
:
[ICSSoft.STORMNET.NotStored())
[StrLen(255))
[DataServiceExpression(typeof(SQLDataService), "isnull(@FirstName@,\'\') \' \' isnull(@LastName@,\'\')"))
public virtual string FullName
{
get
{
return string.Format("{0} {1}", fFirstName, fLastName);
}
set
{
}
}
In the attribute DataServiceExpression
defined the expression that will be used service data when you run the query from the table.
Is equivalent to this expression on the C# code is written in the getter of the properties.
IDataService dataService = DataServiceProvider.DataService;
LoadingCustomizationStruct lcs = LoadingCustomizationStruct.GetSimpleStruct(typeof(Person), Person.Views.Person_E);
// Load all the data objects. Nechranice property will be computed using the expressions in the getter.
ICSSoft.STORMNET.DataObject[) persons = dataService.LoadObjects(lcs);
// Load in the form of string representation, the properties are separated from each other by semicolons. Nechranice property will be computed using the expressions in the attribute DataServiceExpression.
ObjectStringDataView[) osdvpersons = dataService.LoadStringedObjectView(';', lcs);
Console.WriteLine("OK.");