DataObjects-NET / dataobjects-net

https://dataobjects.net
MIT License
60 stars 23 forks source link

`DefaultExpression` is not supported. #312

Closed SergeiPavlov closed 1 year ago

SergeiPavlov commented 1 year ago

We are using Automapper package to generate projecting expressions for DO Queries. Beginning with version Automapper 12.0.1 DataObject fails to translate query with error: Xtensive.Orm.QueryTranslationException : Unable to translate ...

We found that Automapper generates DefaultExpression object which cannot be processed by DO. Can be reproduced by code like this:

var param = Expression.Parameter(typeof(Location), "o");
var lambda = Expression.Lambda<Func<Location, int>>(
      Expression.Condition(
            Expression.Equal(param, Expression.Default(typeof(object))),
                Expression.Constant(1),
                Expression.Constant(2)),
           false,
       new[] { param });

var result = Session.Query.All<Location>().Select(lambda);

If we replace Expression.Default(typeof(object)) by Expression.Constant((object)null) it does work.

alex-kulakov commented 1 year ago

Hello, How about this #313 ?

SergeiPavlov commented 1 year ago

Hello, How about this #313 ?

Tested it with AutoMapper 12.0.1. The translation errors are gone. Great work!

alex-kulakov commented 1 year ago

Nice! I'm merging the PR.