急! Linq查询问题
XPQuery<TableA> tableA= new XPQuery<TableA>(XpoHelper.XpoSession);
ASPxGridView1.DataSource = from A in tableA
join B in
(from C in tableA
group C by C.type into g
select new { type= g.Key, time = g.Max(p => p.time) })
on A.type equals B.type
where A.time == B.time
select A;
ASPxGridView1.DataBind();
总是报错:Cannot resolve ClassInfo for type '[]<>f__AnonymousType0`2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'
我这个查询的目的是从tableA这个表里查出每种type中时间最新的那个,单独跑
from C in tableA
group C by C.type into g
select new { type= g.Key, time = g.Max(p => p.time) }
这个是没问题的,可以正常选出type和最大时间,但是再根据选出的值查找所有信息时就出错了,B中所有的值都不能用,都报上面那个错误,我尝试在数据库里直接写存储过程,这个方法没有问题,但是用linq就不行,实在不知道错在哪里了,希望大家帮帮忙!
LINQ
------解决方案--------------------XPQuery<TableA> tableA= new XPQuery<TableA>(XpoHelper.XpoSession);
ASPxGridView1.DataSource = from A in tableA
join B in
(from C in tableA
group C by C.type into g
select new
TableA { type= g.Key, time = g.Max(p => p.time) })
on A.type equals B.type