Created
August 26, 2017 17:56
-
-
Save JeremyLikness/bfd29e0fed5ac2bc896437e8dac82ffc to your computer and use it in GitHub Desktop.
A strongly-typed MongoDB query
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var projection = Builders<FoodItem>.Projection | |
| .Include(fi => fi.FoodId) | |
| .Include(fi => fi.FoodGroupId) | |
| .Include(fi => fi.Description) | |
| .Include(fi => fi.ShortDescription); | |
| var query = db.GetCollection<FoodItem>(Collections.GetCollectionName<FoodItem>()); | |
| var findFluent = query.Find(fi => fi.Description.Contains(search)); | |
| var projectedQuery = findFluent.Limit(100).Project(projection); | |
| await projectedQuery.ForEachAsync(item => { // do something }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment