Subsonic Query Design for Hiding (Guid)

I have a table of "Notes". Notes support one level of streaming β€” in other words, you can answer a note, but you cannot answer another answer. So the table looks something like this:

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 use Active Subsonic 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 go through IQueryable and populate the general list of notes. Guides:

List<Guid> noteList = new List<Guid>();
foreach (var note in allNotes)
{
     noteList.Add(note.NoteId);
}

Finally, I am trying to build a query to get all responses 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 get is: "The method" Contains "is not supported." Any ideas?

EDIT: I tried converting the strings to the following strings:

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.

+3
2

, List < > . Subsonic.

IEnumerable < > . Contains, :

IEnumerable<string> noteListEnumerable = noteList;

replies = from n in Note.All()
          where n.ParentNoteId != null && noteListEnumerable.Contains(n.ParentNoteId.Value)
          select n
+10

, , . , , .

+1

Source: https://habr.com/ru/post/1728657/


All Articles