c# - Linq to SQL Strange SQL Translation -


i have simple query generating odd sql translations, blowing code when object saturated.

from x in datacontext.myentities select new  {     istypecda = x.entitytype == "cda"  } 

i expect query should translate to:

select (case when [t0].[entitytype] = @p1 1 else 0 end) [istypecda] ... 

instead :

select  (case      when @p1 = [t0].[entitytype] 1     when not (@p1 = [t0].[entitytype]) 0     else null  end) [istypecda] ...  

since i'm saturating poco istypecda bool, blows stating can't assign null bool.

any thoughts?

edit: fixed property names make sense...

from x in datacontext.myentities select new {   istypecda = x.entitytype == null  } 

c# interpretation (false) or sql interpretation (null)?

this runs in sql sql interpretation. that's why funky translation - operation return nullable bool.

use query punt nullable bool plain old bool.

from x in datacontext.myentities select new {   istypecda = ((bool?)(x.entitytype == "cda")) ?? false } 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -