Skip to content

ToList before Where in ToDoController  #52

Description

@giuliohome

When you useToList you transform IQueryable in IEnumerable and so you wrongly select the user's todos in memory.

public ActionResult Index()

{

var currentUser = manager.FindById(User.Identity.GetUserId());

return View(db.ToDoes.ToList().Where(todo => todo.User.Id == currentUser.Id));

}

You should delete the above said ToList in order to optimize the Where condition into the linq/EF autogenerated SQL

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions