Nhibernate Linq Error on Single or Default
I'm pulling my hair out over here and I'm not sure what's causing it.
I have the following LINQ query:
return Session.Linq<CandidateAccountEntity>().SingleOrDefault(p => p.UserName.ToLower().Equals(userName.ToLower()));
and its throwing the following error:
Index was out of range. Must be non-negative and less than the size of the collection.
If I try to wrap it with a check of:
if(Session.Linq<CandidateAccountEntity>().Any()) {...}
t开发者_运维问答hen I get the following error:
could not execute query [ SELECT count(*) as y0_ FROM [CandidateAccountEntity] this_ inner join CFG.Account this_1_ on this_.AccountEntity
1_id=this_1_.AccountId ] [SQL: SELECT count(*) as y0_ FROM [CandidateAccountEntity] this_ inner join CFG.Account this_1_ on this_.AccountEntity
1_id=this_1_.AccountId]
with an inner exception of:
{"Incorrect syntax near '`'."}
Any help would be greatly, greatly apperciated. I don't want to get stuck here on friday afternoon :/
ToLower is not supported in the NH 2.x Linq provider. It works with the integrated provider in 3.x.
精彩评论