Telerik blogs

Today we had a great turn out for the Q1 2010 What’s New in OpenAccess, and JustCode webinar.  However, we got a great deal of questions at the end so I am going to do my best to cover all of these questions here on my blog :)  This entry will aim to better explain the context object you saw me use in the webinar, and hopefully clarify a few things for everyone.  The first couple of question I want to answer are below.

1. So are we basically throwing out the old way of OpenAccessing data?....don't need to create scopes, and dispose of them...etc?

Currently, if you want to use forward mapping you will still have an ObjectScopeProvider in your DAL project.  However, if you are doing reverse mapping, and create a new “Telerik OpenAccess Domain Model” then you will be using the new OpenAccessContext object.  There are a few things to keep in mind when using the new context object. The first being, that under the covers the new context object does use IObjectScope.   It is hidden from you, and wrapped up in a pretty, easy to use package, but you do still need to dispose of your context object when you are done :)  You do not need to create an object scope manually however.

   1: using( ModelContext mc = new ModelContext())
   2: {
   3:     listBox1.DataSource = mc.Products.ToList();
   4: }

2. So with no scopes now...are all transactions persisted instantly instead of batched till a commit?

No,  you still must commit any changes to the database with the .SaveChanges() method of the OpenAccessContext .  If you are not seeing this method, then make sure you have added a reference to: Telerik.OpenAccess.35.Extensions.dll

3.  I saw you were able to get data from the database without using an objectscope. is that replaced by the :context?

When you use the “Telerik OpenAccess Domain Model” yes, this context object will be created for you, and this is what you will use to access your data.

I hope this helps clear up a few things.  We will be getting some videos together soon that will further illustrate the use of the new features.  I am currently creating a simple web project that will show a few examples of using the OpenAccessContext object.  So stay tuned :)


Comments are disabled in preview mode.