-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Fix #2852 - Support Enum.HasFlag in LINQ #5576
Conversation
At first I tried to create IMethodCallTranslator, but it never get called, because the argument type of Enum.HasFlag() is a System.Enum, and it's not mapped to any CLR type. |
@divega , @rowanmiller - Are we looking to take this one in? |
@smitpatel we discussed moving it to the 1.0.1 milestone in triage. |
Ok. Thanks! |
@smitpatel you are good to take a look at this now (for the 1.1 release) |
namespace Microsoft.EntityFrameworkCore.Query.ExpressionTranslators | ||
{ | ||
public class EnumHasFlagTranslator : IExpressionFragmentTranslator | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Derive directly from IMethodCallTranslator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I tried to create IMethodCallTranslator, but it never get called, because the argument type of Enum.HasFlag() is a System.Enum, and it's not mapped to any CLR type.
So, I changed to IExpressionFragmentTranslator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should not cause any issue since, the argument would be either parameter or constant. For both the cases, we try to find database mapping for the underlying type (which is necessary because we need to represent the argument in SQL) and if that is non-null then translator should get called.
@fujiy - Can you update the PR according to feedback? |
I'll try again with IMethodCallTranslator. But I'm having some issues running the unit tests in Visual Studio |
@fujiy - Will it fine if I use this PR as starting point and do required modification on top of it before merging? |
Ok. No problem. I'm still having issues running the unit tests. |
Completed via #6431 |
Fix #2852 - Support Enum.HasFlag in LINQ