Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Last active September 29, 2017 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/52e63d08abcd73a513f22983bcc89a1b to your computer and use it in GitHub Desktop.
Save NMZivkovic/52e63d08abcd73a513f22983bcc89a1b to your computer and use it in GitHub Desktop.
public async Task<List<User>> GetAllUsers()
{
return await _usersCollection.Find(new BsonDocument()).ToListAsync();
}
public async Task<List<User>> GetUsersByField(string fieldName, string fieldValue)
{
var filter = Builders<User>.Filter.Eq(fieldName, fieldValue);
var result = await _usersCollection.Find(filter).ToListAsync();
return result;
}
public async Task<List<User>> GetUsers(int startingFrom, int count)
{
var result = await _usersCollection.Find(new BsonDocument())
.Skip(startingFrom)
.Limit(count)
.ToListAsync();
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment