【发布时间】:2015-06-18 09:18:40
【问题描述】:
我有一张包含房产详细信息的表格
------------------------------------------------
Id | Propertyname |date_created |Price |agent_name
------------------------------------------------
1 |xxxxxx |17-06-2015 |10000 |abc
2 |xxyyyyy |15-06-2015 |10000 |abc
3 |xxyyyyy |16-06-2015 |10000 |bcd
4 |xxyyyyy |15-06-2015 |10000 |bcd
5 |xxyyyyy |17-06-2015 |10000 |cde
6 |xxyyyyy |15-06-2015 |10000 |cde
我想要一个结果
------------------------------------------------
Id | Propertyname |date_created |Price |agent_name
------------------------------------------------
1 |xxxxxx |17-06-2015 |10000 |abc
3 |xxyyyyy |16-06-2015 |10000 |bcd
5 |xxyyyyy |17-06-2015 |10000 |cde
我想要一个具有不同 agent_name 且具有完整行详细信息的结果
我试过下面的代码
var property =
from l in properties
group l by l.agent_name into g
let lastUsed = g.OrderBy(x => x.date_created).Last()
select lastUsed;
Adove 代码显示错误
LINQ to Entities 无法识别方法“properties Lastproperties”方法,并且该方法无法转换为存储表达式。
任何人都知道如何解决这个问题
【问题讨论】:
-
您包含的代码中没有
properties LastProperties方法,所以我猜您的问题出在其他地方。简短的回答是 EF 不能将任意方法转换为 SQL。 -
properties 是表名