below is my sql query
select *
from test1View
where test1ID in (select distinct(test2ID) from test2Result)
I want this query in Linq please
below is my sql query
select *
from test1View
where test1ID in (select distinct(test2ID) from test2Result)
I want this query in Linq please
You can do as below to achieve where in functionality in linq
DataClassesDataContext db = new DataClassesDataContext();
List<int> lstGroups = db.APP3_FRM2GRPs.Where(x => x.FGR_FRM_PKEY == Convert.ToInt32(ddlForms.SelectedValue)).Select(b => b.FGR_GRP_PKEY).ToList<int>();
var qry = from item in db.APP3_GROUPs
where lstGroups.Contains(item.GRP_PKEY)
select item;
IQueryable<int> subQuery = db.Test2Result
.Select(tr => tr.Test2Id)
.Distinct();
IQueryable<Test1View> query = db.Test1View
.Where(tv => subQuery.Contains(tv.Test1ID);