Unable to translate 'Query.All().Where(a => (a.VirtualDateTime.Value.Date == .Now.Date))

public DateTime? VirtualDateTime { get; set; }

using custom compiler: Expression<func<entity2, datetime?="">> exp = a => a.LinkWithDate.DateField; cfg.LinqExtensions.Register(typeof(Entity2).GetProperty("VirtualDateTime"), exp);

Code:

namespace ConsoleApplication2
{
    using System;
    using System.Linq;
    using System.Linq.Expressions;

    using Xtensive.Orm;
    using Xtensive.Orm.Configuration;

    [HierarchyRoot]
    [Serializable]
    public class TestEntity : Entity
    {
        [Field][Key]
        public Guid Id { get; private set; }

        [Field]
        public DateTime DateField { get; set; }
    }

    [HierarchyRoot]
    [Serializable]
    public class Entity2 : Entity
    {
        [Field][Key]
        public Guid Id { get; private set; }

        public DateTime? VirtualDateTime { get; set; }

        [Field]
        public TestEntity LinkWithDate { get; set; }
    }

    public class ConsoleApplication2
    {
        public static void Main()
        {
            var connectionInfo = new ConnectionInfo("sqlserver", "Data Source=.; Initial Catalog=TestDb; Integrated Security=True;");
            var cfg = new DomainConfiguration(connectionInfo);
            cfg.UpgradeMode = DomainUpgradeMode.Recreate;
            cfg.Types.Register(typeof(TestEntity).Assembly);

            Expression<Func<Entity2, DateTime?>> exp = a => a.LinkWithDate.DateField;
            cfg.LinqExtensions.Register(typeof(Entity2).GetProperty("VirtualDateTime"), exp);

            var domain = Domain.Build(cfg);
            using (var s = domain.OpenSession())
            {
                using (s.Activate())
                {
                    using (var tr = s.OpenTransaction())
                    {
                        s.Query.All<Entity2>().Where(a => a.VirtualDateTime.Value.Date == DateTime.Now.Date).ToArray();
                        tr.Complete();
                    }
                }
            }
        }
    }
}

asked Mar 20 '13 at 06:55

pil0t's gravatar image

pil0t
207575763

Hello pil0t, we will investigate your problem. Thanks for the report

(Mar 21 '13 at 14:39) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

The problem is confirmed

(Apr 01 '13 at 04:02) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

2 Answers:

Hello pil0t,

fix would be available in DO 4.5.8/4.6.4

answered Apr 29 '13 at 06:45

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

А когда эта версия будет доступна?

answered Jul 15 '13 at 08:37

k_v_kuznetsov's gravatar image

k_v_kuznetsov
34226

Our current plan is to release this until the end of this month

(Jul 16 '13 at 02:56) Denis Krjuchkov Denis%20Krjuchkov'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