M
Matthijs de Z
Hi,
I want to run a linq query on an entity table linke this:
var myGroupNameIDvar = (from selecteddonwloadgroup in
db.SelEcTedDonWLoadGroup
where
selecteddonwloadgroup.DownloadGroupName == "test"
select
selecteddonwloadgroup).First();
if the query is able to return a row, there's no problem. But if there
is no data to return, because "test" doesn't exist, I get the error
"Operation is not valid due to the current state of the object".
When I use singeOrDefault() teher is no problem. But default will be 0
in this case and that could be linked to something else. So I would
like to first check if the query returns data, if so..I'll get the ID
(which is an uint).
Can anybody help me out how to work around this problem.
Regards,
Matthijs
I want to run a linq query on an entity table linke this:
var myGroupNameIDvar = (from selecteddonwloadgroup in
db.SelEcTedDonWLoadGroup
where
selecteddonwloadgroup.DownloadGroupName == "test"
select
selecteddonwloadgroup).First();
if the query is able to return a row, there's no problem. But if there
is no data to return, because "test" doesn't exist, I get the error
"Operation is not valid due to the current state of the object".
When I use singeOrDefault() teher is no problem. But default will be 0
in this case and that could be linked to something else. So I would
like to first check if the query returns data, if so..I'll get the ID
(which is an uint).
Can anybody help me out how to work around this problem.
Regards,
Matthijs