I use DataObjects.Net v4.4.0 Beta 1
In App.config
<domain name="Default" upgradeMode="Recreate" connectionUrl="sqlserver://localhost
MyEntity.cs
using System;
using Xtensive.Orm;
namespace BugTest.Model
{
[Serializable]
[HierarchyRoot]
public abstract class SomeEntity : Entity
{
protected SomeEntity(Session session) : base(session)
{
}
[Field, Key]
public int Id { get; private set; }
[Field(Length = 100)]
public string Text { get; set; }
}
[Serializable]
public class FirstEntity : SomeEntity
{
public FirstEntity(Session session) : base(session)
{
}
[Field]
[Association(PairTo = "Owner")]
public EntitySet<FirstChild> entSet { get; set; }
}
[Serializable]
public class SecondEntity : SomeEntity
{
public SecondEntity(Session session) : base(session)
{
}
[Field]
[Association(PairTo = "Owner")]
public EntitySet<SecondChild> entSet { get; set; }
}
[Serializable]
public class MyEntity<TEntity> : Entity where TEntity : Entity
{
[Field, Key]
public int Id { get; private set; }
[Field(Length = 100)]
public string Text { get; set; }
[Field]
public TEntity Owner { get; set; }
public MyEntity(Session session, TEntity entity)
: base(session)
{
Owner = entity;
}
public MyEntity(Session session)
: base(session)
{
}
}
[Serializable]
[HierarchyRoot]
public abstract class NextEntity : MyEntity<SomeEntity>
{
public NextEntity(Session session) : base(session)
{
}
protected NextEntity(Session session, SomeEntity entity) : base(session, entity)
{
}
}
[Serializable]
public class FirstChild : NextEntity
{
public FirstChild(Session session, SomeEntity entity) : base(session, entity)
{
}
public FirstChild(Session session) : base(session)
{
}
}
[Serializable]
public class SecondChild : NextEntity
{
public SecondChild(Session session)
: base(session)
{
}
public SecondChild(Session session, SomeEntity entity) : base(session, entity)
{
}
}
}
Program.cs
using System;
using System.Linq;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;
using BugTest.Model;
namespace BugTest
{
class Program
{
static void Main(string[] args)
{
// Loading configuration section for in-memory database.
// See other cases in App.config file.
var config = DomainConfiguration.Load("Default");
var domain = Domain.Build(config);
using (var session = domain.OpenSession())
{
using (var transactionScope = session.OpenTransaction())
{
// Creating new persistent object
var first = new FirstEntity(session)
{
Text = "first!"
};
// Creating new persistent object
var second = new SecondEntity(session)
{
Text = "second!"
};
new FirstChild(session, first) { Text = "First" };
new SecondChild(session, second) { Text = "Second" };
// Committing transaction
transactionScope.Complete();
}
}
using (var session = domain.OpenSession())
{
using (var transactionScope = session.OpenTransaction())
{
Console.WriteLine(session.Query.All<SecondChild>().First().Text);
Console.WriteLine(session.Query.All<FirstChild>().First().Text);
}
}
Console.ReadKey();
}
}
}
But if I use in App.config
<domain name="Default" upgradeMode="Recreate" connectionUrl="memory://localhost
Everything works fine. I think this is your bug.
asked
Apr 28 '11 at 02:33
Multysh
15●6●6●9
Hello Multysh,
What is the purpose of using 4.4 beta 1 when the final 4.4 version is already released? Could you please upgrade to the latest version and check whether the case still presents.
I update to 4.4 with revision 7460
Bug not fix
Thanks.
Will check this.