namespace Project2.Model
{
    using System;
    using Xtensive.Orm;

    [Serializable]
    [HierarchyRoot]
    public class BaseClass : Entity
    {
        public BaseClass(Session session) : base(session)
        {
        }

        [Field, Key]
        public int Id { get; set; }
    }

    class Children : BaseClass
    {
        public Children(Session session) : base(session)
        {
        }

        [Field]
        public bool SomeBool { get; set; }
    }
}

program.cs

    using System;
    using Xtensive.Orm;
    using Xtensive.Orm.Configuration;
    using Project2.Model;

    namespace Project2
    {
        using System.Linq;

        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())
                    {
                        var t = session.Query.All<BaseClass>().ToArray();
//Work ok
                        var k = session.Query.All<Children>().Where(a => t.Contains(a as BaseClass)).ToArray();
//But without cast we have fail
                        var m = session.Query.All<Children>().Where(a => t.Contains(a)).ToArray();

                    }
                }
                Console.ReadKey();
            }
        }
    }

It's ok or bug?

asked Sep 05 '11 at 04:46

Multysh's gravatar image

Multysh
15669

edited Sep 05 '11 at 05:22

Hello,

is the issue actual for In-Memory database only or for any kind of storage?

(Sep 06 '11 at 03:25) Dmitri Maximov Dmitri%20Maximov's gravatar image

the issue is actual for any kind of storage

(Sep 06 '11 at 03:35) Multysh Multysh's gravatar image

The bug is confirmed. Will fix it.

(Sep 06 '11 at 04:12) Dmitri Maximov Dmitri%20Maximov's gravatar image

One Answer:

Fixed in 7897 (1c5ff57aefb6)

answered Nov 10 '11 at 08:33

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

The bug is actually not fully fixed, see:

class Children : BaseClass
{
    [Field]
    public BaseClass Base { get; set; }
    [Field]
    public bool SomeBool { get; set; }
}

All the following queries fail:

var t = s.Query.All<Children>().ToArray();
var m1 = s.Query.All<Children>().Where(a => t.Contains(a.Base)).ToArray();
var m2 = s.Query.All<Children>().Where(a => (t as IEnumerable<BaseClass>).Contains(a.Base)).ToArray();
var n = s.Query.All<Children>().Where(a => a.Base.In(t)).ToArray();
(Nov 30 '11 at 09:20) xumix xumix's gravatar image
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