dotnet / dotnet/fsharp

Linq Expression translation is off

Open
#11,332 3 comments 1 reaction 0 assignees View on GitHub
Area-Quotations Bug Impact-Medium
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

This is primarily seen in libraries like EF core that take the C# translation as canonical (and often don't recognize F# translations). However this case warrants a bit of extra investigation in my opinion, it's a very verbose translation that probably doesn't need to be like this.

https://github.com/dotnet/efcore/issues/14013

Translation error:

> The LINQ expression 'where (copyOfStruct => (copyOfStruct != null).Invoke([x].creationDate) AndAlso (copyOfStruct => Convert(copyOfStruct, DateTimeOffset).Invoke([x].creationDate) < 30/11/2018 11:01:57 +00:00))' could not be translated and will be evaluated locally.

Original expression:
```fs
// the lambda here is the expression pointed to in the error
context.Blogs.Where(fun x -> x.creationDate.HasValue && x.creationDate.Value < now)
```

We need to establish if this is by design from the F# side and if it is not implement a fix on this side (I can take this) otherwise we (I) should focus on fixing EF core for 6.0.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.