Browse by Date

0

Well I'm using EF with the following code to query it brings the query by name and type but not date, since the time is not in my filter with the 00:00:00 time it brings correctly the time not is part of the research, but it is part of the business rule.

public PaginationResult<Tabela> GetAll(ISpecification<Tabela> specification, Pagination pagination = null, Sorting sorting = null)
{
    var query = Tabela.Where(specification.SatisfiedBy());
    var result = new PaginationResult<Schedule>();

    if (sorting != null)
    {
        query = query.OrderBy(sorting.ToString());
    }
    result.TotalItems = query.Count();
    if (pagination != null)
    {
        query = query.Skip(pagination.CurrentPage * pagination.ItemsPerPage).Take(pagination.ItemsPerPage);
    }

    result.Items = query.ToList();
    return result;
}

O specification

specification = 
          specification.And(Specification<tabela>.Create(e => e.data.Equals(filter.data)));
    
asked by anonymous 26.06.2017 / 15:15

1 answer

2

If a hora não faz parte da pesquisa , I believe you can get only the portion of the date by adding .Date to the date of the objects when creating the specification:

specification = specification.And(Specification<tabela>.Create(e => DbFunctions.TruncateTime(e.data) <= filter.data.Date));
    
26.06.2017 / 15:35