Open Sparkles-Laurel opened 3 years ago
Seems strange. I use LINQ as follows:
var document= _database.GetCollection<T>();
return document.Find(predicate);
where a predicate would be anything from `c=> c.customerId == '1234'
I have a fucntion like this:
/// <summary>
/// Get All items by expression
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="predicate"></param>
/// <returns></returns>
public IEnumerable<T> GetItems<T>(Expression<Func<T, bool>> predicate = null) where T : DbItem, new()
{
var document = _db.GetCollection<T>();
return document.Find(predicate);
}
I just wondered why I couldn't use the query syntax on an ILiteCollection. (LINQ provides two query synatxes: query syntax and method syntax.)
I think this is related to that LiteDB is a NoSQL database.
I was trying to query an ILiteCollection<> object (reference may be more suitable) with LINQ, as how I could just query an IEnumerable<>:
and this caused the compilation error below:
Why cannot I use LINQ queries directly on an ILiteCollection?