public async Task<IEnumerable<dynamic>> GetPaginatedResultAsync(long pageNumber)
{
if (string.IsNullOrWhiteSpace(this.Database))
{
return null;
}
if (!this.SkipValidation)
{
if (!this.Validated)
{
await this.ValidateAsync(AccessTypeEnum.Read, this.LoginId, this.Database, false).ConfigureAwait(false);
}
if (!this.HasAccess)
{
Log.Information(
$"Access to Page #{pageNumber} of the entity \"{this.FullyQualifiedObjectName}\" was denied to the user with Login ID {this.LoginId}.");
throw new UnauthorizedException("Access is denied.");
}
}
long offset = (pageNumber - 1)*PageSize;
string sql = $"SELECT * FROM {this.FullyQualifiedObjectName} WHERE deleted=@0 ORDER BY {this.PrimaryKey}";
sql += FrapidDbServer.AddOffset(this.Database, "@1");
sql += FrapidDbServer.AddLimit(this.Database, PageSize.ToString());
return await Factory.GetAsync<dynamic>(this.Database, sql, false, offset).ConfigureAwait(false);
}