我有以下兩個表:,最大骨料選擇記錄使用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