DO 5.0.16 Sample

using System.Linq;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;

internal class Program
{
    private static int ItemId => 1;

    private static void Main(string[] args)
    {
        var dc = new DomainConfiguration("sqlserver", "Data Source=.; Initial Catalog=DO40-Tests; Integrated Security=True;");

        dc.Types.Register(typeof(TestEntity));
        dc.UpgradeMode = DomainUpgradeMode.Recreate;

        using (var d = Domain.Build(dc))
        {
            using (var s= d.OpenSession())
            using (s.Activate())
            using (var t = s.OpenTransaction())
            {
                var ids = new[] { 1, 2 };

                Query.All<TestEntity>().Count(e => ItemId.In(ids)); // OK
                Query.All<TestEntity>().Count(e => ids.Contains(ItemId)); // FAIL

                t.Complete();
            }
        }
    }
}

[HierarchyRoot]
public class TestEntity : Entity
{
    /// <summary>Initializes a new instance of this class.</summary>
    /// <param name="session">The session.</param>
    public TestEntity(Session session) : base(session)
    {
    }

    [Key]
    [Field(Nullable = false)]
    public int Id { get; private set; }
}

Exception

Unhandled Exception: Xtensive.Orm.QueryTranslationException: Unable to translate 'Query.All().Count(e => @.ids.Contains(.ItemId))' expression. See inner exception for details. ---> System.NullReferenceException: Object reference not set to an instance of an object.
 at Xtensive.Orm.Linq.Expressions.Visitors.IncludeFilterMappingGatherer.VisitMemberAccess(MemberExpression m)
 at Xtensive.Linq.ExpressionVisitor`1.Visit(Expression e)
 at Xtensive.Linq.ExpressionVisitor.VisitBinary(BinaryExpression b)
 at Xtensive.Orm.Linq.Expressions.Visitors.IncludeFilterMappingGatherer.VisitBinary(BinaryExpression b)
 at Xtensive.Linq.ExpressionVisitor`1.Visit(Expression e)
 at Xtensive.Orm.Linq.Expressions.Visitors.IncludeFilterMappingGatherer.Gather(Expression filterExpression, Expression filterDataTuple, ApplyParameter filteredTuple, Int32 columnCount)
 at Xtensive.Orm.Linq.Translator.VisitExistsAsInclude(Expression source, LambdaExpression predicate, Boolean notExists)
 at Xtensive.Orm.Linq.Translator.VisitExists(Expression source, LambdaExpression predicate, Boolean notExists)
 at Xtensive.Orm.Linq.Translator.VisitContains(Expression source, Expression match, Boolean isRoot)
 at Xtensive.Orm.Linq.Translator.VisitQueryableMethod(MethodCallExpression mc, QueryableMethodKind methodKind)
 at Xtensive.Linq.QueryableVisitor.VisitMethodCall(MethodCallExpression mc)
 at Xtensive.Orm.Linq.Translator.VisitMethodCall(MethodCallExpression mc)
 at Xtensive.Linq.ExpressionVisitor`1.Visit(Expression e)
 at Xtensive.Orm.Linq.Translator.Visit(Expression e)
 at Xtensive.Orm.Linq.Translator.VisitLambda(LambdaExpression le)
 at Xtensive.Orm.Linq.Translator.VisitWhere(Expression expression, LambdaExpression le)
 at Xtensive.Orm.Linq.Translator.VisitAggregateSource(Expression source, LambdaExpression aggregateParameter, AggregateType aggregateType, Expression visitedExpression)
 at Xtensive.Orm.Linq.Translator.VisitAggregate(Expression source, MethodInfo method, LambdaExpression argument, Boolean isRoot, MethodCallExpression expressionPart)
 at Xtensive.Orm.Linq.Translator.VisitQueryableMethod(MethodCallExpression mc, QueryableMethodKind methodKind)
 at Xtensive.Linq.QueryableVisitor.VisitMethodCall(MethodCallExpression mc)
 at Xtensive.Orm.Linq.Translator.VisitMethodCall(MethodCallExpression mc)
 at Xtensive.Linq.ExpressionVisitor`1.Visit(Expression e)
 at Xtensive.Orm.Linq.Translator.Visit(Expression e)
 at Xtensive.Orm.Linq.Translator.Translate[TResult]()
 at Xtensive.Orm.Linq.QueryProvider.Translate[TResult](Expression expression, CompilerConfiguration compilerConfiguration)
 --- End of inner exception stack trace ---
 at Xtensive.Orm.Linq.QueryProvider.Translate[TResult](Expression expression, CompilerConfiguration compilerConfiguration)
 at Xtensive.Orm.Linq.QueryProvider.Translate[TResult](Expression expression)
 at Xtensive.Orm.Linq.QueryProvider.Execute[TResult](Expression expression)
 at System.Linq.Queryable.Count[TSource](IQueryable`1 source, Expression`1 predicate)
 at Sample.Program.Main(String[] args) in C:\Projects\CleanDO\Sample\Program.cs:line 27

asked Jan 09 at 06:20

Gushchin%20Anton's gravatar image

Gushchin Anton
75911


One Answer:

Hello Anton,

The issue is confirmed and solved in developing branch. Wait it in one following releases

answered Jan 31 at 07:41

Alexey%20Kulakov's gravatar image

Alexey Kulakov
58215

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