EF4 - What's all the hype over objectsets?
- by Kohan
I am an intermediate user of EF in .net 3.5 and have recently moved to working with .net 4.
One think i keep coming across when reading various tutorials is the use of ObjectSets instead of ObjectQuerys and that they are a great new feature.
What is so great about them?
Reading this MSDN article titled "Working with ObjectSet (Entity Framework)" It shows two examples for on how to add a Product.. one for 3.5 and another for 4.0.
http://msdn.microsoft.com/en-us/library/ee473442.aspx
Though my lack of knowledge I am possibly bringing up a seperate point here, but i never added a Product like this:
//In .NET Framework 3.5 SP1, use the following code:
using (AdventureWorksEntities context = new AdventureWorksEntities())
{
// Add the new object to the context.
context.AddObject("Products", newProduct);
}
I would have just used context.AddToProducts(newProduct);
Please enlighten me.
Kind regards,
Kohan