Does any one know the difference, if any, of the following statements?
_context.AddObject(user);
_context.Users.AddObject(user);
as well as
_context.Attach(user);
_context.Users.Attach(user);
Thanks
EDIT
Sorry some confusion:
I know the difference between AddObject and Attach, what I meant was is there any difference in the way you use AddObject i.e.
_context.AddObject(user);
_context.Users.AddObject(user);
An ObjectContext can have multiple sets with the same schema, so it's normally better to use the explicit set. ie _context.Users.AddObject(user);
From MSDN:
In the .NET Framework version 4, we recommend that you use methods on the ObjectSet object to perform create, read, delete, attach, and update operations. ObjectSet derives from ObjectQuery, so it also works as a query object.
In versions starting with .NET Framework version 4, you can use the following methods defined on ObjectSet instead of the equivalent ones defined on ObjectContext:
AddObject Attach ApplyCurrentValues ApplyOriginalValues DeleteObject Detach
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With