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's gravatar image

khoroshevj
15112

Version DO 4.6.6

(Jun 17 '14 at 08:53) khoroshevj khoroshevj's gravatar image

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?

(Jun 23 '14 at 01:09) Alexey Kulakov Alexey%20Kulakov's gravatar image

Hi,

We use it to get typed elements from IQueryable during serialization.

Can you provide me any information about solving time?

(Jun 23 '14 at 08:14) khoroshevj khoroshevj's gravatar image

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.

(Jun 24 '14 at 01:23) Alexey Kulakov Alexey%20Kulakov's gravatar image

Reproduce in 5.0-RC DO

(Jul 29 '14 at 02:47) k_v_kuznetsov k_v_kuznetsov's gravatar image

One Answer:

Problem fixed in DO 4.6.8 and 5.0.0-RC2

answered Aug 06 '14 at 01:20

Alexey%20Kulakov's gravatar image

Alexey Kulakov
63215

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA