When using ORM, after we have setup the business objects, it's useful if we create some generic methods which can be used in many places.
An example would be an add method, which adds new object (record) into the database.
public static void Add(ref T ObjectRef) {
IObjectScope scope = ObjectScopeProvider.GetNewObjectScope();
scope.Transaction.Begin();
scope.Add(ObjectRef);
scope.Transaction.Commit();
scope.Dispose();
}
Now, to use it, simply do:
Add(ref cp);
If you think this post is useful, please recommend me at the bottom of the page. ;)