In NHibernate there is a Save(entityObject) method, which creates a new row in the database with the given entity object, also, has an Update(entityObject) which updates the row corresponding to the entity object with the property values of this object. It also has a SaveOrUpdate(entityObject) method, which checks the whether the entity object corresponds to an existing row in the database, and chooses whether to call Save(…) or Update(…) based on that.

The way I usually do web applications across multiple tiers, when not using view models specifically, makes me encapsulate much code in Services layer that sometimes does not need to care about whether the given entity is persisted in database or not. Thus wanted to have similar method using Entity Framework as ORM.

Of course I have implemented the method number of times and the code evolved based on which version of Entity Framework I’m coding against, and my knowledge of the framework internals as well.  Actually, when you work with so many ORMs like I did, a new ORM or ORM version turns to only sound like “What’s new in the manual?” thing.

, , , , , ,

msdn_code_gallery

Microsoft has recently opened a new sub-site of MSDN, MSDN Code Gallery. Here’s their main statement:

Download and share sample applications, code snippets and other resources

MSDN Code Gallery is your destination for downloading sample applications and code snippets , as well as sharing your own resources.

Usually, people would go for community sites for code samples sharing, or create some open source area like CodePlex, creating projects that only work as sample base. Others would use those or the sample codes available in different MSDN dev centers from time to time for downloading code samples.
Now, we have the place for those little snippets :).

Start Downloading Code Samples and Create Your Own Right Away!

, , ,