Code:
using System;
using System.Linq;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;
public static class Program
{
private static void Main(string[] args)
{
var dc = new DomainConfiguration("sqlserver://localhost/DO40-Tests");
dc.Types.Register(typeof(Test));
dc.Types.Register(typeof(Test2));
dc.UpgradeMode = DomainUpgradeMode.Recreate;
var sessionConfiguration = new SessionConfiguration(SessionOptions.AutoActivation);
using (var domain = Domain.Build(dc))
{
using (var session = domain.OpenSession(sessionConfiguration))
using (var t = session.OpenTransaction())
{
var test2 = new Test2();
var test = new Test
{
Name = "",
Struct = new StructType { Item = test2 }
};
t.Complete();
}
using (var session = domain.OpenSession(sessionConfiguration))
using (var t = session.OpenTransaction())
{
var test2 = Session.Current.Query.All<Test2>().SingleOrDefault();
var result2 = test2.StructSet.OfType<Test>().ToList();
}
}
}
}
[HierarchyRoot]
public class Test : Entity
{
[Key]
[Field(Nullable = false)]
public Guid Id { get; private set; }
[Field]
public string Name { get; set; }
[Field]
public StructType Struct { get; set; }
}
[HierarchyRoot]
public class Test2 : Entity
{
[Key]
[Field(Nullable = false)]
public Guid Id { get; private set; }
[Field]
[Association(PairTo = "Struct.Item")]
public EntitySet<Test> StructSet { get; set; }
}
public class StructType : Structure
{
[Field]
public Test2 Item { get; set; }
}
Error: Unable to translate '$<queryhelper.ownerwrapper<test2>>(Xtensive.Orm.Linq.QueryHelper+OwnerWrapper`1[TestDO.Test2]).Owner.StructSet.OfType()' expression. See inner exception for details.
asked
Jun 17 '14 at 08:52
khoroshevj
15●1●1●2
Version DO 4.6.6
Hello khoroshevj.
It is a bug. Thank you for report. Why do you use OfType method? Do you use EntitySet of some interface in real application?
Hi,
We use it to get typed elements from IQueryable during serialization.
Can you provide me any information about solving time?
Hello khoroshevj.
Unfortunately, this bug wasn't fixed in 4.6.7. We will fix it in 4.6.8, but i don't know exact release date yet.
Reproduce in 5.0-RC DO