0 Replies - 417 Views - Last Post: 08 February 2019 - 09:01 AM

#1 ahmedba   User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 220
  • Joined: 24-January 14

How to check id exist or not generic repository pattern ASP.NET core 2

Posted 08 February 2019 - 09:01 AM

Problem

How to check id exist or not generic repository pattern asp.net core 2.1 ?


because i have more than 10 controllers so that i need to write function check

if id on table exist or not .

like that
if (!EmployeeExists(emp.EmployeeId))
                    {
                        return NotFound();
                    }



What I have tried:

I try that by this not work


bool CheckIfEntityExistsByEntityId(Expression<Func<T, bool>> expr);
public bool CheckIfEntityExistsByEntityId<T>(Expression<Func<T, bool>> expr)
        {
            return dbSet.Any(u => expr);
        }


I have compile error on expr

Is This A Good Question/Topic? 0
  • +

Page 1 of 1