0
In this method, I populate my 'rule' variable with all rules coming from Select, however, I would like to filter only Status = True. How to do this?
public async Task<BootgridResponseViewModel<ConsultaIntramexRegrasResponse>> ObterListaRegrasConsultaIntramex(BootgridRequestViewModel request)
{
using (var ctx = new IntramexContext())
{
var regras = ctx.ConsultaIntramexRegras.AsQueryable().Select(p => new ConsultaIntramexRegrasResponse
{
Id = p.Id,
Descricao = p.Descricao,
Periodicidade = p.Periodicidade,
DiaSemanaMes = p.DiaSemanaMes,
Horario = p.Horario,
CodigoConsulta = p.CodigoConsulta,
OperadorRegistroId = p.OperadorRegistroId,
Status = p.Status,
UltimaExecucao = p.UltimaExecucao
}).Distinct();
if (!string.IsNullOrWhiteSpace(request.searchPhrase))
{
regras = regras.Where(p => p.Descricao.Contains(request.searchPhrase)
|| p.Periodicidade.ToString().Contains(request.searchPhrase)
|| p.Descricao.ToString().Contains(request.searchPhrase)
|| p.OperadorRegistroId.ToString().Contains(request.searchPhrase));
}
var dados = await regras.OrderByDescending(m => m.Id).AplicaFiltroAsync(request).ConfigureAwait(false);
return dados;
}
}
Perfect @LINQ, Tks!
– Bruno Souza