(SubSonic) I have this initial declaration to do a simple join.
var ji = from pli in PriceListItem.All( )
join ci in CatalogItem.All( ) on pli.CatalogItemID equals ci.CatalogItemID
select new { pli = pli, ci = ci };
Before executing the sql, under some circumstance, I want to add a join to an in-memory list. When I code
var Results =
from SID in priceListItemID
join pli in PriceListItem.All( ) on SID equals pli.PriceListItemID
join ci in CatalogItem.All( ) on pli.CatalogItemID equals ci.CatalogItemID
select new { pli = pli, ci = ci };
I get a SQL query for the CatalogItem table, then one for the PriceListItem table, then the joins (including the in-memory list) occur in code.
Trying to avoid this, my code is this:
List<Guid> priceListItemID = new List<Guid>( );
...some code follows that fills the list, then
ji = ji.Join( priceListItemID, p => p.pli.PriceListItemID, i => i, ( p, i ) => p );
then, eventually,
foreach( var r in ji )
Without the additional join, this is OK. Adding a where clause (instead of the join),
IEnumerable<Guid> guids = priceListItemID;
ji = ji.Where( p => guids.Contains( p.pli.PriceListItemID ) );
is also OK. However, with the join, there comes the exception: "the expression of type 'System.Collections.Generic.IEnumerable`1[System.Guid]' is not a sequence.