这是我的加入:
var jCorsi = from t in db.Table1
join j in db.Table2 on t.IDCourse equals j.IDCourse
select new { t, j };
我需要(稍后使用其他查询)才能使用两个表的字段。 例如:
var testx = (from j in jCorsi
group j by j.IDCourse into g
但它说“找不到j.IDCourse
的定义”,即使我选择了t和j。
我哪里错了?
答案 0 :(得分:2)
你应该做
var testx = (from j in jCorsi
group j by j.t.IDCourse into g
select ...
(j.t.
代替j.
)
也许最好让它更明确:
var jCorsi = from t in db.Table1
join j in db.Table2 on t.IDCourse equals j.IDCourse
select new { Table1 = t, Table2 = j };
var testx = (from x in jCorsi
group x by x.Table1.IDCourse into g
select ...
答案 1 :(得分:0)
var jCorsi = from t in table1
join j in table2 on t.IDCourse equals j.IDCourse
select new { t, j };
var testx = from j in jCorsi
group j by j.t.IDCourse into g
select g;