15.8. Adding, Updating, and Deleting Objects

The processes of adding, updating, and deleting objects is simple; you just have to keep in mind that these actions must be performed within the scope of a transaction.

To add an object, you need to create a new instance of a class that represents the object, add it to the scope provider, and call the Commit() method. See Listing 15-14.

Example 15.14. Adding a New Object
IObjectScope nwd = NorthwindScopeProvider.ObjectScope();
    var cat = new Category();
    cat.CategoryName = "Oriental Imports";
    cat.Description = "Food imported from Asia";
    cat.DisplayOrder = 100;
catch (Exception)

For updating records, ...

Get Pro Telerik ASP.NET and Silverlight Controls: Master Telerik Controls for Advanced ASP.NET and Silverlight Projects now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.