我有两个linq查询,我想在一个查询中使用另一个查询的结果。
var t2s = (from temp3 in _ent.Products
where temp3.Row_Num == 2
select new { temp3.ProductID });
然后我在另一个查询中使用这个变量:
var _query = (from P1 in _ent.brands
join temp2 in on
new { Produ_ID = (Int32?)P1.Prod_ID }
equals new { Produ_ID = (Int32?)temp2.ProductID }
);
当我单独运行第一个查询时,它会给我正确的结果。如果我不使用
join
运行第二个查询,它也会给我正确的结果,但是使用join
运行时会出现以下错误:
错误:无法创建类型为“匿名类型”的常量值。只有原始类型(如Int32、String和Guid)在此上下文中得到支持。
t2s
在哪里? - Denys Denysenko