1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] IQueryable with Linq to find string part in datetime

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 3, 2024 às 16:33.

  1. Stack

    Stack Membro Participativo

    What I want to do is allow the user to search for part of the date that is shown in the result set.

    Table of results

    ID | Name | Date
    1 Bob 31 August 2018
    2 Bill 29 June 2000
    31 Foo 1 June 2005


    There is a search box and if the user searches for say "31", I need to then construct an IQueryable<> with Linq and Entity Framework 6

    var searchValue = "31"

    var data = IQueryable<T>

    data.Where(x => x.Date.ToString("D").Contains(searchValue)
    || x.Id.Contains(searchValue)
    || x.Name.Contains(searchValue)).Take(x).Skip(Y)


    The result should be

    ID | Name | Date
    1 Bob 31 August 2018
    31 Foo 1 June 2005


    But the results are always null.

    The table I am searching has about 500,000 records. It works across everything apart from the date.

    Continue reading...

Compartilhe esta Página