public async Task <T[]> FindAsync(Query.Query query = null, SortDescription[] sorts = null, int skip = 0, int take = int.MaxValue) { var documents = await Database.Connection.SqlDatabaseProvider.FindAsync(Database, Name, _typeReflector, query, sorts, skip, take); return(documents.Select(_ => { var documentObject = Database.Connection.JsonSerializer.Deserialize <T>(_.Json); SetObjectId(documentObject, _.Id); return documentObject; }).ToArray()); }
public async Task <int> CountAsync([NotNull] Query.Query query) { Validate.NotNull(query, nameof(query)); return(await Database.Connection.SqlDatabaseProvider.CountAsync(Database, Name, _typeReflector, query)); }
public static async Task <T> FindFirstOrDefaultAsync <T>(this NsCollection <T> collection, Query.Query query, params SortDescription[] sorts) where T : class { Validate.NotNull(collection, nameof(collection)); Validate.NotNull(query, nameof(query)); return((await collection.FindAsync(query: query, sorts: sorts ?? SortDescription.OrderById(), skip: 0, take: 1)).FirstOrDefault()); }