Query mongoDB with C# LINQ

Query mongoDB with C# LINQ

1. Project
    Get property of the model directly from the database.

Eg:
var isActive = await collection.Find(a => a.userID == userId).Project(s => s.IsActive).FirstOrDefaultAsync();

without using:
var isActive = (await collection.FindAsync(a => a.userID == userId).Result.FirstOrDefaultAsync()).IsActive;

which gets the entire model and query it for the property; IsActive.

Comments

Popular posts from this blog

Deploy Angular 8 app to Azure with Azure DevOps

Apache ActiveMQ 5 with .Net Core 3.1 and C#

Firebase with.Net Core and C#