Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete support of NullConditionalExpression in ExpressionEqualityComparer #7559

Closed
azabluda opened this issue Feb 6, 2017 · 1 comment
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@azabluda
Copy link

azabluda commented Feb 6, 2017

Since c9b5916#diff-5cd571c8981e88fd1f098652b72cf947R254 ExpressionEqualityComparer computes hash for NullConditionalExpression but still doesn't implement the comparison which leads to an exception.

Exception message: The method or operation is not implemented.

Stack trace:
System.NotImplementedException
The method or operation is not implemented.
   at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionEqualityComparer.ExpressionComparer.Compare(Expression a, Expression b)
   at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionEqualityComparer.ExpressionComparer.CompareBinary(BinaryExpression a, BinaryExpression b)
   at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionEqualityComparer.ExpressionComparer.CompareLambda(LambdaExpression a, LambdaExpression b)
   at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionEqualityComparer.ExpressionComparer.CompareExpressionList(IReadOnlyList`1 a, IReadOnlyList`1 b)
   at System.Collections.Generic.ObjectEqualityComparer`1.Equals(T x, T y)
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at Microsoft.Extensions.Caching.Memory.MemoryCache.TryGetValue(Object key, Object& result)
   at Microsoft.Extensions.Caching.Memory.CacheExtensions.TryGetValue[TItem](IMemoryCache cache, Object key, TItem& value)
   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)

Steps to reproduce

Execute the query from the standard Null_conditional_simple test twice

[Fact]
public virtual void Null_conditional_simple_TWICE()
{
    var c = Expression.Parameter(typeof(Customer));

    var predicate
        = Expression.Lambda<Func<Customer, bool>>(
            Expression.Equal(
                new NullConditionalExpression(c, c, Expression.Property(c, "CustomerID")),
                Expression.Constant("ALFKI")),
            c);

    using (var dbContext = CreateContext())
    {
        var qry = dbContext.Customers.Where(predicate);
        qry.ToList(); // compile, cache and execute query [PASS]
        qry.ToList(); // fetch cached query and execute [FAIL]
    }
}

Further technical details

EF Core version: 1.1.0
Database Provider: InMemory
Operating system: Windows 7 Pro
IDE: Visual Studio 2015

@rowanmiller rowanmiller added this to the 2.0.0 milestone Feb 10, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.0.0 Apr 19, 2017
azabluda added a commit to azabluda/InfoCarrier.Core that referenced this issue Apr 28, 2017
@anpete
Copy link
Contributor

anpete commented Jun 8, 2017

Verified fixed.

@anpete anpete closed this as completed Jun 8, 2017
@anpete anpete added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants