public async Task<dynamic> GetNextAsync(object primaryKey)
{
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 the get the next entity of \"{this.FullyQualifiedObjectName}\" by \"{this.PrimaryKey}\" with value {primaryKey} was denied to the user with Login ID {this.LoginId}");
throw new UnauthorizedException("Access is denied.");
}
}
//$"SELECT * FROM {this.FullyQualifiedObjectName} WHERE {this.PrimaryKey} > @0
//ORDER BY {this.PrimaryKey} LIMIT 1;";
var sql = new Sql($"SELECT * FROM {this.FullyQualifiedObjectName} WHERE deleted=@0", false);
sql.Where($"{this.PrimaryKey} > @0", primaryKey);
sql.OrderBy(this.PrimaryKey);
sql.Append(FrapidDbServer.AddOffset(this.Database, "@0"), 0);
sql.Append(FrapidDbServer.AddLimit(this.Database, "@0"), 1);
return (await Factory.GetAsync<dynamic>(this.Database, sql).ConfigureAwait(false)).FirstOrDefault();
}