Wed, 04 Mar 2009 |
Filed in:
LINQ
SQL
Have been trying to use Telerik Open Access ORM for the core framework. Finally have the basic structure setup. With having business objects layer, persistant classes and data access layer seperated, the web app itself could just communicate with the business objects, which then calls to persistant classes and data access layer.
Using business object layers could greatly minimise the pain when updating and retrieving data in the database. Dealing with objects is just great and saves a lot of time. Telerik ORM allows many different database technologies to be used and the one I am using is LinQ to SQL. Here's some basic ones to remember:
To Retrieve an object with id:
var result = from c in scope.Extent() where c.CompanyID == id select c;
To Retrieve a set of result with a limit:
var result = (from c in scope.Extent() select c).Skip(0).Take(intLimit); return result.ToList();
To update an object:
you must first retrieve the object out and then update it before committing it.
If you think this post is useful, please recommend me at the bottom of the page. ;)