✅ Ef Core unexpected query behaviour
For some reason it's not including
MemberRole.admin
. It's including MemberRole.Write
?27 Replies
After changing the comparison statement to
om.Role != MemberRole.None
all of a sudden it's working.
I would still like to understand why though?Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
That is how it works unless you copied
MemberRole
or the check wrongUnknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I kind of disagree. It makes sense if you can order the roles like this by the magnitude of privilege. It may make sense to wrap it in a struct to denote which operations are supposed to be used, because it may not be obvious that the members in the enum are ordered accordingly
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
TeBeCo
else nothing's wrong out of the ordinary
you need to debug your data and see what's going on
Quoted by
<@689473681302224947> from #Ef Core unexpected query behaviour (click here)
React with ❌ to remove this embed.
I thought it would just compare the value assigned to the
enum
which is an int
. So it sort of made sense. I guess om.Role != MemberRole.None
makes more sense.Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I do have a conversion though which might have led to the issue.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I see what you mean. Very good point.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
It's a bit easier to read on the database side. Since I'm doing a lot of debuging at this stage.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
Not really no. 🤣
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
you can make a table for roles and join with it when you need a human readable output
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
that's what people usually do
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
To be honest, I'm not very familiar with sql directly. I don't have a lot of knowledge in that field. That's why I'm using ef core.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
Oh I see.
Thank you guys very much for the input. I learned some new stuffs.
don't avoid learning SQL
I have always wanted to learn. I just forget the syntax for some reason. 🤣
If you have no further questions, please use /close to mark the forum thread as answered