1
Vote

Bad query with LINQ with a and operator

description

With a simple model like this:
 
<Class name="Page" >
  <Property name="PageName" type="System.String" />
  <Property name="IsVisible" type="System.Boolean" />
</Class>
<Class name="Site" >
  <Property name="Name" type="System.String" />
</Class>
<Relationship type="">
  <Parent name="Page" multiplicity="*" role="" />
  <Child name="Site" multiplicity="1" role="Site" />
</Relationship>
 
the following linq query works well
 
from Page p in oc where p.Site.Id == sid select p
 
but if I add another where parameter
 
from Page p in oc where p.Site.Id == sid & p.IsVisible == true select p
 
I have no results.
 
I think that underlying opath (and sql) query is wrong
 
[exists(Site[id('e8d9620a-61cd-4f68-b32e-43feb134fb84')]) and id('e8d9620a-61cd-4f68-b32e-43feb134fb84') and IsVisible = true]
 
FROM [Site] AS [e2] INNER JOIN [Page] AS [e1] ON ([e1] .[FK_Site] = [e2] .[SiteId] ) WHERE ([e2] .[SiteId] IN ('e8d9620a-61cd-4f68-b32e-43feb134fb84' ) )
And (([e0] .[FK_Site] = [e1] .[FK_Site] ) ) ) And [e0] .[PageId] IN ('e8d9620a-61cd-4f68-b32e-43feb134fb84' ) ) And ([e0] .[IsVisible] = 1 ) ) )
 
because the PageId constraint with a Site guid (e8d9620a-61cd-4f68-b32e-43feb134fb84)
 
A linq query translator problem?
 
Regards,
 
Giovanni Livi

comments