I've got a very basic database schema and have created a dbml from it. Two tables are related in a one-to-many. (A)1-*(B) ... hence each A gets an EntitySet called "BSet".
If I do:
foreach (var a in db.A)
{
Console.WriteLine(a.Name);
foreach (var b in a.BSet)
{
Console.WriteLine(b.Number);
}
}
I find that it prints out the same set of B's for each A. If I debug the L2S SQL Log I can see its creating the correct SQL each time it calls BSet. In spite of that it prints the same set of Bs for each A.
If I write a LINQ Select statement then I get the correct result.
Whats broken in the foreach? I am usually pretty good with LINQs subtleties but this one is confusing me!