1

I have the below method in the EF Core application

    public List<Prj_Detail> GetByOrg(string org)
    {
        var data = _context.Prj_Details.Where(w => w.Account_Name == org).ToList();
        return data;
    }

Here instead of == I need to check for Like how can I do that in my method

trx
  • 2,077
  • 9
  • 48
  • 97

3 Answers3

4

Like others have said you can do a Contains operator however in some cases this casues an unncessary TSQL casting. Instead you could use the in-built Entity Framework functions like so:

_context.Prj_Details.Where(EF.Functions.Like(w.Account_Name, org)).ToList();
Kane
  • 16,471
  • 11
  • 61
  • 86
0

Have you tried using Contains?

var data = _context.Prj_Details.Where(w => w.Account_Name.Contains(org)).ToList();

You can use StartsWith and EndsWith too.

Here's more information about it.

Brugner
  • 527
  • 8
  • 16
0

Could try with Contains to filter.

Please refer the below code. depending on LeftRim/RightTrim/upperCase/LowerCase

    public List<Prj_Detail> GetByOrg(string org)
    {
        var data = _context.Prj_Details.Where(w => w.Account_Name.Contains(org)).ToList();
        return data;
    }
Nivas Pandian
  • 416
  • 1
  • 7
  • 17