Error in AsNoTracking()
I don't know why it show this error.
NOMOR is string and unique value.
35 Replies
and this is my code
.Count()
is getting the count based on your condition, it is no longer a iqueryable, it is an intBased on condition what is mean? i used count to get data for NOMOR since NOMOR is unique value i thought this right using count π
i still confusing why is it no longer iqueryable is it because the "count"? sorry i'm still learning
Count literally gets the count. So doing anything else linq related after it doesn't make sense
Okey i get it, then i was trying to make it like this one but my 'e' error tooπ΅
@Kouhai can you help me? I'm sorry for pinging you π π
No problem
what's the issue?
I want to try get data by nomor since NOMOR is unique value i try to use count or distant but didn't work
Okay, both Count and Distinct work differently that what you probably expect.
You could do
I tried this before but it give me data not found
LaporanPenilaian.NOMOR
is a string, right?yes string
Alright, try running
FindByNomor
with a value you're 100% sure it exists, does return null
?This is actually my controller. Yes it's null
Just to be sure, the current implementation is this?
yes kou
i use this
How about this
This won't do any comparisons, but just for a quick test
This workπ
Great, what value did it return?
It gives return the data
Oops
I just realized NOMOR is being encoded
but i tried to input wrong nomor after it return the same result
To answer the actual question here: just call
AsNoTracking
on the set before you do anything else
before the where, before the count etcOkay, use this again
And make sure to call it
FindByNomor(Uri.UnescapeDataString(NOMOR))
Thanks it I don't know this > And make sure to call it FindByNomor(Uri.UnescapeDataString(NOMOR)) what's this actually?
NOMOR is being url encoded, basically you have characters like
/
which is used as a separator in URLs, that character when passed as a query parameter for instance get's encoded to %2F
by default it's not decoded back to /
If you look at your input
And how it's actually being requested
You'll see that
/
became %2F
Uri.UnescapeDataString
just decodes the string back to it's original formatOMG Kuo, you gave me an answer that i was looking for before, was i trying to find how to decode this cause NOMOR was unique code. Thank you so muchπ
No problem
kuo i want to ask, i just don't understand why, i tried on local about this ok, i got the data, but when i tried on server production error.
Are there any exceptions?