DB.DBEntities ent = new DB.DBEntities();
foreach (var brn in ent.Sites.ToList())
{
//Do work
}
If I try above code, it gives Unreachable code on var branch
But if I store the list in another list object and iterate on it, no warning is given.(As below)
DB.DBEntities ent = new DB.DBEntities();
List<DB.Site> list = ent.Sites.ToList();
foreach (var brn in list)
{
//Do work
}
Can some one please explain why does this happen?