filter linq to sql with a entity framework where in

I am doing 2 linq queries one with entity framework and the other is linq to sql and they are not playing well together at all.

The first query grabs id's that are in one table via entity framework.

var pemdata = from pd in db.tblMap 
                          where pd.PID == pid
                          select new 
                              eid = pd.EID

And then I'm filtering the second query using a contains via linq to sql.

var data = from e in p.entities 
                       join et in p.entity_types on e.entity_type equals et.entity_types_id

                       where pemdata.Contains(e.entity_id) 

                       select new gEntities
                           entity_type = e.entity_type.ToString(),
                           Name = e.entity_name,
                           Type = et.entity_types_name,
                           Address = e.entity_address,
                           City = e.entity_city,
                           Zip = e.entity_zip.ToString()

The issue I'm seeing is an error.

Instance argument: cannot convert from 'System.Linq.IQueryable' to 'System.Linq.ParallelQuery'

'System.Linq.IQueryable' does not contain a definition for 'Contains' and the best extension method overload 'System.Linq.ParallelEnumerable.Contains(System.Linq.ParallelQuery, TSource)' has some invalid arguments

I usually don't have a problem doing a contains like this. but when I'm mixing linq to sql and entity framework I get this issue.

Any thoughts?


You'll need to materialize the first query before using the results. Easiest way is to just call .ToList() on it. Then you can use the results in the second query.

var pemdata = (from pd in db.tblMap 
                          where pd.PID == pid
                          select pd.EID).ToList();

Need Your Help

MPI_Finalize() doesn't finalize

c linux mpi

#include <stdio.h>