I have a simple query that is generating some odd SQL translations, which is blowing up my code when the object is saturated.
from x in DataContext.MyEntities select new { IsTypeCDA = x.EntityType == "CDA" } I would expect this query should translate to:
SELECT (CASE WHEN [t0].[EntityType] = @p1 THEN 1 ELSE 0 END) as [IsTypeCDA] ... Instead I get this :
SELECT (CASE WHEN @p1 = [t0].[EntityType] THEN 1 WHEN NOT (@p1 = [t0].[EntityType]) THEN 0 ELSE NULL END) AS [IsTypeCDA] ... Since I'm saturating a POCO where IsTypeCDA is a bool, it blows up stating I can't assign null to bool.
Any thoughts?
Edit: fixed the property names so they make sense...
DOCUMENT_TYPEthe column theEntityTypeproperty is mapped to? It looks like you muddied the waters when you cleaned up the generated SQL.MyEntitiesproperty and of what type isEntityType.CDA?MyEntitiesis a table,MyEntities.EntityTypeis a stringEntityTypeis a static class andEntityType.CDAis a constant string. basicallyMyEntities.EntityTypecan be any of n values, but only a handful are important in the scope of this query.