Esempio n. 1
0
 public static async Task <T> FindFirstOrDefaultAsync <T>(this NsCollection <T> collection, Expression <Func <T, bool> > query, params SortDescription[] sorts)
     where T : class
 {
     Validate.NotNull(collection, nameof(collection));
     Validate.NotNull(query, nameof(query));
     return((await collection.FindAsync(query: QueryBuilder <T> .Build(query), sorts: sorts ?? SortDescription.OrderById(), skip: 0, take: 1)).FirstOrDefault());
 }
Esempio n. 2
0
        public static async Task <int> CountAsync <T>(this NsCollection <T> collection, Expression <Func <T, bool> > query) where T : class
        {
            Validate.NotNull(collection, nameof(collection));
            Validate.NotNull(query, nameof(query));

            return(await collection.CountAsync(QueryBuilder <T> .Build(query)));
        }
Esempio n. 3
0
        public static async Task <T[]> FindAsync <T>(this NsCollection <T> collection, Expression <Func <T, bool> > query, params SortDescription[] sorts) where T : class
        {
            Validate.NotNull(collection, nameof(collection));
            Validate.NotNull(query, nameof(query));

            return(await collection.FindAsync(QueryBuilder <T> .Build(query), sorts));
        }
Esempio n. 4
0
        public async Task <NsCollection <T> > GetCollectionAsync <T>(string collectionName) where T : class
        {
            Validate.NotNullOrEmptyOrWhiteSpace(collectionName, nameof(collectionName));

            var collection = new NsCollection <T>(this, collectionName);

            await collection.EnsureTableAsync();

            return(collection);
        }
Esempio n. 5
0
 public static async Task EnsureIndexAsync <T>(this NsCollection <T> collection,
                                               Expression <Func <T, object> > query, bool unique = false, bool ascending = true)
     where T : class
 {
     await collection.EnsureIndexAsync(QueryBuilder <T> .BuildPath(query), unique, ascending);
 }
Esempio n. 6
0
 public static async Task <T> FindFirstOrDefaultAsync <T>(this NsCollection <T> collection, params SortDescription[] sorts)
     where T : class
 {
     Validate.NotNull(collection, nameof(collection));
     return((await collection.FindAsync(sorts: sorts ?? SortDescription.OrderById(), skip: 0, take: 1)).FirstOrDefault());
 }
Esempio n. 7
0
 public static async Task <T[]> FindAllAsync <T>(this NsCollection <T> collection, params SortDescription[] sorts)
     where T : class
 {
     Validate.NotNull(collection, nameof(collection));
     return(await collection.FindAsync(sorts : sorts ?? SortDescription.OrderById()));
 }