我有一個「註釋」表。 Notes支持一種線程級別 - 換句話說,您可以回覆註釋但不能回覆其他回覆。所以表看起來像下面這樣:Subsonic查詢構建包含(Guid)
CREATE TABLE [dbo].[Notes] (
[NoteId] [uniqueidentifier] ROWGUIDCOL NOT NULL DEFAULT (newid())
CONSTRAINT [PK__Notes]
PRIMARY KEY ([NoteId]),
[ParentNoteId] UNIQUEIDENTIFIER NULL,
[NoteText] NVARCHAR(MAX) NOT NULL,
[NoteDate] DATETIME NOT NULL
)
所以我用亞音速活動記錄讓所有的「父」註釋:通過IQueryable的
var allNotes = (from n in Note.All()
where n.ParentNoteId == null
orderby n.NoteDate descending
select n)
.Skip((pageIndex - 1) * pageSize).Take(pageSize);
接下來,我只是循環,並填寫通用筆記的GUID列表:
List<Guid> noteList = new List<Guid>();
foreach (var note in allNotes)
{
noteList.Add(note.NoteId);
}
最後,我要建一個查詢來獲取所有的回覆來自原始查詢說明:
replies = from n in Note.All()
where n.ParentNoteId != null && noteList.Contains(n.ParentNoteId.Value)
select n
我收到的錯誤是:「方法‘包含’不支持」任何想法?
編輯:我試圖轉換爲字符串如下所示:如前所述
List<String> noteList = new List<String>();
foreach (var note in allNotes)
{
noteList.Add(note.NoteId.ToString());
}
replies = (from n in Note.All()
where n.ParentNoteId != null &&
noteList.Contains(n.ParentNoteId.Value.ToString()) select n);
相同的錯誤消息。
IEnumerable工作。謝謝您的幫助。 – sestocker 2010-01-18 14:22:29