Using HasFlag in an Entity Framework query #14
Answered
by
alirezanet
YousefAK009
asked this question in
Q&A
-
|
Can use HasFlag in EF query? query.Where(x => x.Permission.HasFlag(Permissions.AllowEdit)).ToList(); |
Beta Was this translation helpful? Give feedback.
Answered by
alirezanet
Oct 28, 2023
Replies: 1 comment 4 replies
-
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @yousefak007,
Apologies for the confusion earlier. I initially misunderstood your question, thinking it was related to my other open-source project, Gridify 🫠. Please disregard my previous response. (I deleted it)
Regarding the database side, using HasFlag directly is not feasible because your database doesn't inherently support custom enum functionality. You can, however, retrieve the relevant data into memory and then check permissions there.
If you're working with a SQL Server database, you might consider creating a custom function in C# and incorporating it into your database. Keep in mind that this approach could potentially impact query performance.
A bit of context: InfiniteE…