Full list of code examples Flexberry ORM is in “code Examples”.

the Creation and preservation of an object with a large number of datalow

This test carries out generation of a large object graph metalowymi links and store it in a database. Used class diagram has the form:

All classes inherited from nehrenovo abstract class D. For each array of datalow each object is generated by 10 detailov, then everything is stored in the database by passing the data service the root object of the graph.

Console.WriteLine("5. Create a dataobject with multiple details.");

// Create a data object that has multiple metalowych properties. 
D0 aggregator = new D0();

// Call method metalowych objects. Method code is shown below. 
// The hierarchy of datalow arranged in such a way that when you set the number of datalow 10 for each object 
// the total number of data objects will exceed 30000. 
OrmSample ormSample = new OrmSample();
ormSample.GenDetails(aggregator, 10);

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();

// The objects are stored in order corresponding to the relations between them (from the root to the tips). 
DataServiceProvider.DataService.UpdateObject(aggregator);

stopwatch.Stop();
Console.WriteLine("Time taken for persistence: {0} ms.", stopwatch.ElapsedMilliseconds);

Method GetDetails:

internal void GenDetails(D dobj, int qtyInEach)
{
    RandomStringGenerator rsg = new RandomStringGenerator();
    dobj.Name = rsg.Generate(200);
    dobj.S1 = rsg.Generate(200);
    dobj.S2 = rsg.Generate(200);
    dobj.S3 = rsg.Generate(200);
    dobj.S4 = rsg.Generate(200);
    dobj.S5 = rsg.Generate(200);

    string[] detprops = Information.GetPropertyNamesByType(dobj.GetType(), typeof(DetailArray));
    for (int i = 0; i < detprops.Length; i++)
    {
        DetailArray detarr = (DetailArray)Information.GetPropValueByName(dobj, detprops[i]);
        Type dettypetocreate = Information.GetCompatibleTypesForDetailProperty(dobj.GetType(), detprops[i])[0];
        for (int j = 0; j < qtyInEach; j++)
        {
            D newobj = (D)Activator.CreateInstance(dettypetocreate);
            GenDetails(newobj, qtyInEach);
            detarr.AddObject(newobj);
        }
    }
}