我有以下两个表:,最大骨料选择记录使用LINQ to SQL
DocumentType
Id INT,
Name VARCHAR(100),
Active BIT,
CreatedBy INT
Document
Id INT,
DocumentTypeId INT,
Version SMALLINT,
Text NTEXT
我想选择DocumentType
及相关Document
纪录最大值为Version
。我想下面的查询:
from t in Documents
join tt in DocumentTypes on t.DocumentTypeId equals tt.Id
where tt.CreatedBy == 10
group t by t.DocumentTypeId into g
//let v = new {Version = g.Max(t => t.Version), TypeId =g.Key}
select new
{
Key = g.Key,
Version = g.Max(t=>t.Version),
Text = t.Text //ERROR AT t.Text
};
,但它给我一个错误在以下行:
Text = t.Text
The name 't' does not exist in the current context
我试图g.Text
也,但它并没有帮助。请帮我解决这个问题。我在LinqPad上尝试了这个。
人,这是好的,问题是在'文本= t.Text'到来。由于分组,它期望有一些聚合运算符,但它不能用于'NTEXT'类型的列。 – TheVillageIdiot 2013-02-21 05:36:14