Delete or remove records in .net core (c#) using linq.

Aman Sharma

Delete one Record:

If you want to remove only one record, use Remove method.


var user = _context.Users.Where(u => u.UserId == item.UserId) .FirstOrDefault();

    if (user!= null) {





Delete records in bulk:

If you want to delete records in bulk, user RemoveRange method.

  var userRoles = _context.UserRoles.Where(u => u.UserId == item.UserId);

  if (userRoles!= null) {




Post a Comment

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !