Let\'s say I have two EntitySets, \"Teams\" and \"Players\".
I am adding new teams to the system, for sake of argument, let\'s say I\'m adding a thousand teams from
No there is no way to make them behave the same. ObjectSet represents database query and once you use it you are always doing query to the database where your new team is not present yet. EntityCollection is local collection of loaded entities and if you use it you are doing query to your application memory.
Generally using EntityCollection is exactly same as maintaining separate List:
List teams = context.Teams.ToList();
var team = teams.FirstOrDefault(t => t.Name == newTeam.Name);
if (team == null)
{
context.Teams.AddObject(newTeam);
teams.Add(newTeam);
}
context.SaveChanges();
You can also use Dictionary and get probably better performance instead of searching the list for each team.