Posted by Alec on Fri, 06 Mar 2009, in ASP.NET C# Telerik
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);