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
  • 1,985
  • 8
  • 39
  • 84

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,027
  • 11
  • 59
  • 84
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
  • 317
  • 9
  • 14
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
  • 377
  • 1
  • 6
  • 15