我在這裏拉我的頭髮,我不知道是什麼原因造成的。Nhibernate Linq單一或默認錯誤
我有以下LINQ查詢:
return Session.Linq<CandidateAccountEntity>().SingleOrDefault(p => p.UserName.ToLower().Equals(userName.ToLower()));
及其引發以下錯誤:
Index was out of range. Must be non-negative and less than the size of the collection.
如果我嘗試用支票來包裝它:
if(Session.Linq<CandidateAccountEntity>().Any()) {...}
那麼我得到以下錯誤:
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]
與內部異常:
{"Incorrect syntax near '`'."}
任何幫助將是很大的,大大apperciated。我不想在星期五下午卡在這裏:/
另請參閱:http://stackoverflow.com/questions/2598202/does-nhibernate-linq-support-tolower-in-where-clauses – 2010-06-19 09:49:09