public async Task <Operation <IPage <TObject> > > GetAsync(string query = null, SortOptions sort = null, PageOptions page = null, FieldOptions fields = null, FilterOptions filter = null, ProjectionOptions projection = null) { _db.SetTypeInfo(typeof(TObject)); if (sort == null || sort == SortOptions.Empty) { sort = SortOptions.FromType <TObject>(x => x.Id); } if (page == null || page == PageOptions.Empty) { page = new PageOptions { Page = 1, PerPage = _options.CurrentValue.PerPageDefault } } ; var sql = _dialect.Build <TObject>(sort, fields, filter, projection); var data = (await _db.Current.QueryAsync <TObject>(PageBuilder.Page(_dialect, sql), new { page.Page, page.PerPage })).AsList(); var total = await _db.Current.ExecuteScalarAsync <long>(_dialect.Count(_descriptor, filter?.Fields)); var slice = new Page <TObject>(data, data.Count, page.Page - 1, page.PerPage, total); return(new Operation <IPage <TObject> >(slice)); }