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

Fix #2852 - Support Enum.HasFlag in LINQ #5576

Closed
wants to merge 1 commit into from
Closed

Fix #2852 - Support Enum.HasFlag in LINQ #5576

wants to merge 1 commit into from

Conversation

felipepessoto
Copy link
Contributor

@felipepessoto felipepessoto commented May 30, 2016

Fix #2852 - Support Enum.HasFlag in LINQ

@felipepessoto felipepessoto changed the title Fix #2852 Fix #2852 - Support Enum.HasFlag in LINQ May 30, 2016
@felipepessoto
Copy link
Contributor Author

felipepessoto commented Jun 1, 2016

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

@smitpatel
Copy link
Contributor

@divega , @rowanmiller - Are we looking to take this one in?

@divega
Copy link
Contributor

divega commented Jun 1, 2016

@smitpatel we discussed moving it to the 1.0.1 milestone in triage.

@smitpatel smitpatel added this to the 1.0.1 milestone Jun 1, 2016
@rowanmiller
Copy link
Contributor

@fujiy you probably already got this from @divega's comment - but given where we are in the 1.0.0 release, we are going to hold off on taking this and ship it in the following release (tentatively 1.0.1). We'll merge your PR once we branch for the 1.0.0 release.

@felipepessoto
Copy link
Contributor Author

Ok. Thanks!

@rowanmiller
Copy link
Contributor

@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
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derive directly from IMethodCallTranslator

Copy link
Contributor Author

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

Copy link
Contributor

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.

@smitpatel
Copy link
Contributor

smitpatel commented Aug 22, 2016

@fujiy - Can you update the PR according to feedback?

@felipepessoto
Copy link
Contributor Author

I'll try again with IMethodCallTranslator. But I'm having some issues running the unit tests in Visual Studio

@smitpatel
Copy link
Contributor

@fujiy - Will it fine if I use this PR as starting point and do required modification on top of it before merging?

@felipepessoto
Copy link
Contributor Author

felipepessoto commented Aug 29, 2016

Ok. No problem.

I'm still having issues running the unit tests.

@smitpatel smitpatel mentioned this pull request Aug 30, 2016
@smitpatel
Copy link
Contributor

Completed via #6431

@smitpatel smitpatel closed this Aug 30, 2016
@felipepessoto felipepessoto deleted the fix2852 branch September 2, 2016 23:30
@ajcvickers ajcvickers removed this from the 1.1.0-preview1 milestone Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants