Linq to sql where [column] in (list of values with other schema)

Linq to sql where [column] in (list of values with other schema)

所以这是一个连接:

var multipleSites = (from cs in dc.CUsersSites
                            join c in dc.CUsers on cs.UserId equals c.UserId
                            where cs.Cid == int.Parse(Session["Cid"].ToString()) && c.UserName == HttpContext.Current.User.Identity.Name
                            select cs).ToList();

架构

CUsersSites (id, UserId, Cid, Siteid)
CUsers (id, UserId, UserName)
Sites (id, Cid, Siteid, FullName)

如何获取所有 Sites,其中 SiteidmultipleSites 列表中?

我试过了:

this.SitesStore.DataSource = from s in dc.Sites
                                  where s.Cid == int.Parse(Session["Cid"].ToString()) && ( multipleSites.Contains(s.Siteid))
                                  select s;

但是我得到这个错误:

Argument 1: cannot convert from 'int' to 'DAL.CUsersSite'

试试这个方法:

this.SitesStore.DataSource = 
dc.Sites.Where(s => multipleSites.Select(ms => ms.Siteid )
.Contains(s.Siteid) && s.Cid == int.Parse(Session["Cid"].ToString())).ToList();