linq2db / LinqToDB.Identity

ASP.NET Core Identity provider that uses LinqToDB.
https://linq2db.github.io/
MIT License
46 stars 9 forks source link

How can I add support for Enum.HasFlag? #20

Closed Nevca closed 4 years ago

Nevca commented 4 years ago

I tried adding support for Enum.HasFlag method to linq2db like follows:

LinqToDB.Linq.Expressions.MapMember((Enum e, Enum e2) => e.HasFlag(e2), (Expression<Func<Enum, Enum, bool>>)((t, flag) => (Sql.ConvertTo<int>.From(t) & Sql.ConvertTo<int>.From(flag)) != 0));

I'm getting the following exception when executing this: Expression of type 'MyEnum' cannot be used for parameter of type 'System.Enum' of method 'Int32 From[Enum](System.Enum)

I'm not sure if I'm doing it right or this is a bug.