Geeks With Blogs


Currently Reading

CLR via C#m
Under The Influence(of code) Abhijeet Patel's blog Entity Framework
Retrieving Added Entities from the ObjectStateManager to avoid duplication
Let's say we neede to process a bunch of entities coming from an XML file, create EDM entites for each XML element and eventually persist them. Very trivial to accomplish using a little bit of LINQ. <Roles> <Role name="Admin"/> <Role name="Reader"/> <Role name="Writer"/> </Roles> var doc = XDocument.Load("Roles.xml"); var roles = doc.Element("Roles").Elemen... => new Role { RoleName = (string)x.Attribute("name") }); PermissionsAPIContext context = ......

Posted On Thursday, July 23, 2009 1:41 AM

Using multiple Object Contexts in a Transaction
The scenario: You have 2 Entity Models, and you need to call operations on the ObjectContext of each of them, the operations should be atomic, in that either both operations should succeed or fail so that your databases are consistent. This is fairly straightforward to accomplish using a TransactionScope. ObjectServices is smart enough to detect if the ObjectContext is in a surrounding TransactionScope and if so,use that scope. NOTE:If a scope is not specified, then ObjectContext by default creates ......

Posted On Wednesday, May 13, 2009 11:58 PM

Entity Framework Object Context - AWAITING COMMAND
Now I know that the Entity Framework has a disconnected data access model i.e. connections to the database and opened and closed only when you retrieve data that has not been retrieved or you explicitly request a call to the database or you call SaveChanges on the ObjectContext. I was really surprised to find that inspite of disposing the ObjectContext, there was still an active connection maintained to the database. The following code fragment shows the typical usage for ObjectContext. Right after ......

Posted On Friday, April 3, 2009 10:43 PM

Some Extension Methods for working with the ADO.NET Entity Framework
Recently I've started working more and more with the ADO.NET Entity framework and I must say that I like it a lot. There are folks who absolutely love EDM and folks that think its really evil. It's still a v1.0 product and I treat it as such. The designer does leave a lot to be desired.A lot of bells and whistles will be added to the VS 2010 release to address a lot of the designer "desirables". It's not been an easy buy in at work for adopting EDM, but my team has been among the first to have adopted ......

Posted On Thursday, March 5, 2009 7:43 PM

Copyright © Abhijeet Patel | Powered by: