次の2つのテーブルがあります。
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でこれを試しています。