I have a "Notes" table. Notes support one level of threading - in other words you can reply to a note but cannot reply to another reply. So the table looks something like the following:
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
)
So I am using Subsonic active record to get all the "parent" notes:
var allNotes = (from n in Note.All()
where n.ParentNoteId == null
orderby n.NoteDate descending
select n)
.Skip((pageIndex - 1) * pageSize).Take(pageSize);
Next I just loop through the IQueryable and fill a generic list of the note Guids:
List<Guid> noteList = new List<Guid>();
foreach (var note in allNotes)
{
noteList.Add(note.NoteId);
}
Finally, I am trying to construct a query to get all the replies to notes from the original query:
replies = from n in Note.All()
where n.ParentNoteId != null && noteList.Contains(n.ParentNoteId.Value)
select n
The error I am receiving is: "The method 'Contains' is not supported" Any ideas?
EDIT: I tried converting to strings like the following:
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);
Same error message as before.