【发布时间】:2010-01-15 16:46:53
【问题描述】:
我有一个“笔记”表。笔记支持一个级别的线程 - 换句话说,您可以回复笔记但不能回复另一个回复。所以表格看起来像下面这样:
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
)
所以我正在使用 Subsonic 活动记录来获取所有“父”注释:
var allNotes = (from n in Note.All()
where n.ParentNoteId == null
orderby n.NoteDate descending
select n)
.Skip((pageIndex - 1) * pageSize).Take(pageSize);
接下来我只是循环遍历 IQueryable 并填写注释 Guids 的通用列表:
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);
与以前相同的错误消息。
【问题讨论】:
标签: c# linq activerecord subsonic subsonic3