2

I Know how entity framework AsNoTracking() method works but i want to know should we use this method also when selecting specific fields of entity?

for example is there any performance benefits between these two queries: (getting result as an anonymous object)

DataContext.Customers.AsNoTracking().Select(x => new { x.FirstName, x.City.Name }).ToList();


DataContext.Customers.Select(x => new { x.FirstName, x.City.Name }).ToList();
Mohammad Zare
  • 1,489
  • 7
  • 25
  • 45
  • 1
    The answer to this question is buried in a comment in the linked answer, "Anonymous classes don't represent the entity itself so they don't have tracking." So AsNoTracking() doesn't matter in this case. – David Browne - Microsoft Nov 26 '18 at 21:11

0 Answers0