I don't know whether it's my mistake or a bug in Devexpres XPO? (Version 12.1.5)
take a look at the following sample:
static void Main(string[] args)
{
var dxs = Session.DefaultSession;
var sw = new Stopwatch();
using (var uow = dxs.BeginNestedUnitOfWork())
{
var dbp = new DBParent(uow) { TitleXX = "Morgan" };
// add 1000 child to the parent table
for (var i = 0; i < 1000; i++)
{
var dbc = new DBChild(uow)
{
Name = string.Format("Child {0}", i),
Parent = dbp
};
}
var count = uow.GetObjectsToSave();
// count = 1001
sw.Start();
uow.CommitChanges();
sw.Stop();
Console.WriteLine("Time:" +sw.Elapsed);
// Takes about 7 sec
}
using (var uow = dxs.BeginNestedUnitOfWork())
{
var dbp = new XPCollection<DBParent>(uow).First();
dbp.TitleXX = "Another title";
dbp.Save();
var count = uow.GetObjectsToSave();
// count = 1
sw.Reset();
sw.Start();
uow.CommitChanges();
sw.Stop();
Console.WriteLine("Time:" + sw.Elapsed); // Takes about 4 sec ????
}
Console.ReadLine();
}
}
and here are my objects :
public class DBParent : XPObject
{
public DBParent(){}
public DBParent(Session session) : base(session) { }
private string _TitleXX;
public string TitleXX
{
get { return _TitleXX; }
set { SetPropertyValue("TitleXX", ref _TitleXX, value); }
}
[Association("a1"), Aggregated]
public XPCollection<DBChild> Childs
{
get
{
return GetCollection<DBChild>("Childs");
}
}
}
public class DBChild : XPObject
{
public DBChild(){}
public DBChild(Session session): base(session){}
private string _Name;
public string Name
{
get { return _Name; }
set { SetPropertyValue("Name", ref _Name, value); }
}
private DBParent _Parent;
[Association("a1")]
public DBParent Parent
{
get { return _Parent; }
set { SetPropertyValue("Parent", ref _Parent, value); }
}
}
as you can see , saving 1001 ( 1000 child + 1 parent ) takes 7 seconds , and in the next block updating 1 parent object is taking 4 seconds. i have tested against MS Access and MS SQL 2008 and MSSQL-Compact , but all have the same result. any advices are appreciated.