Search code examples
c#litedb

LiteDB - Selecting multiple entries with one id


Okay, apologies if the title is misleading, I couldn't find the right wording for it.

So I have a collection from which I want to count all entries with UserId where the StatusId is a value.

I'm looking for something similar/the same as the SQL query below. SELECT COUNT(*) FROM Warns WHERE UserId = uId AND StatusId = sId;

Does something like that exist for LiteDB?


Solution

  • You can use the Count method directly:

    var count = collection.Count(Query.EQ("Field", "Value"));
    

    Or use the standard collection methods:

    var count = query.Run(...).LongCount();