At the moment I have something like this, to check if an Entity has already been added (simplified):
WinEveryBetBYeMiContext context = new WinEveryBetBYeMiContext();
string firstPlayerName = "R.Federer";
foreach (var player in context.Players)
{
if (player.Name == firstPlayerName)
{
//Player already exists
}
}
But since there can be 100s of Players, this approach looks to me very bad and its also very slow..
I heard about LINQ TO SQL.. But I don’t really know if its better, faster and more effective..
Maybe someone has a good way to check such things and could help me out.?
You can use LINQ to make this a bit more efficient and readable: