Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public static string DeleteProjectById(SoftUniContext context)
  2. {
  3. StringBuilder res = new StringBuilder();
  4.  
  5. var epCol = context.EmployeesProjects.Where(x => x.ProjectId == 2).ToList();
  6. foreach (var item in epCol)
  7. {
  8. context.Remove(item);
  9. context.SaveChanges();
  10. }
  11.  
  12. context.Remove(context.Projects.Where(x => x.ProjectId == 2).FirstOrDefault());
  13. context.SaveChanges();
  14.  
  15.  
  16.  
  17. var afterDel = context.Projects.Take(10).ToList();
  18.  
  19.  
  20. foreach (var item in afterDel)
  21. {
  22. res.AppendLine(item.Name);
  23. }
  24.  
  25. return res.ToString().Trim();
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement