我有以下两个表:
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 中尝试这个。