Zum Beispiel basierend auf dem Statuswert, der von der API-Anfrage übergeben wird, kann dieser entweder neu, Fortschritt, erledigt oder einfach null sein. Wenn null, fügen Sie keine where-Bedingung hinzu.
Code: Select all
public async Task GetData(int LitEditJobId)
{
var litEditJob = await context.LitEditJob
.Include(x => x.LitEdit)
.FirstAsync(x => x.JobId == LitEditJobId);
var LitEditTasksQuery = context.Entry(LitEditJob)
.Collection(b => b.LitEditJobTasks)
.Query();
await LitEditTasksQuery
.Where(x => x.State == "new")
.OrderBy(x => x.Id)
.Skip(10)
.Take(10)
.LoadAsync();
return litEditJob;
}
Code: Select all
IQueryable query = new List().AsQueryable();
//I'll add some switch case condition
query = query.Where(t => t.State == LitEditStatus.Progress).OrderBy(x => x.Id).Skip(skip).Take(size);
Code: Select all
public async Task GetData(int LitEditJobId, IQueryable query)
{
query = context.BulkEditJobTask.AsQueryable().Concat(query);
var litEditJob = await context.LitEditJob
.Include(x => x.LitEdit)
.FirstAsync(x => x.JobId == LitEditJobId);
var LitEditTasksQuery = context.Entry(LitEditJob)
.Collection(b => b.LitEditJobTasks)
.Query();
if (query is not null)
{
LitEditTasksQuery = query;
}
await LitEditTasksQuery.LoadAsync(cancellationToken: cancellationToken);
return litEditJob;
}
Mobile version