API Differences
This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.
The purpose of this topic is to illustrate you the most important API differences between Telerik Data Access and LINQ to SQL. After converting your project from LINQ to SQL to Telerik Data Access, it may be no longer buildable. In most of the cases the reason for this will be the various API differences between Telerik Data Access and LINQ to SQL. The purpose of this topic is to help you and guide you into the manual actions you should perform in order to build the converted project.
Saving Changes
In LINQ to SQL you save changes to the underlying database by invoking the SubmitChanges method of the DataContext instance.
DataClasses1DataContext dbContext = new DataClasses1DataContext();
dbContext.SubmitChanges();
Dim dbContext As New DataClasses1DataContext()
dbContext.SubmitChanges()
The corresponding action in Telerik Data Access could be performed via the SaveChanges method of the OpenAccessContext.
NorthwindEntityDiagrams dbContext = new NorthwindEntityDiagrams();
dbContext.SaveChanges();
Dim dbContext As New NorthwindEntityDiagrams()
dbContext.SaveChanges()
Deleting Objects
In LINQ to SQL you can delete rows in a database by removing the corresponding objects from their table-related collection. LINQ to SQL translates your changes to the appropriate SQL DELETE commands.
dbContext.Categories.DeleteOnSubmit(category);
dbContext.Categories.DeleteOnSubmit(category)
In Telerik Data Access you can delete rows by invoking the Delete method of the OpenAccessContext, and passing the target object.
dbContext.Delete(category);
dbContext.Delete(category)
Inserting Data
In LINQ to SQL you insert rows into a database by adding objects to the associated LINQ to SQL Table<TEntity> collection and then submitting the changes to the database.
dbContext.Categories.InsertOnSubmit(newCategory);
dbContext.Categories.InsertOnSubmit(newCategory)
In Telerik Data Access you insert rows into a database by invoking the Add method of the OpenAccessContext and passing the created object. Then you submit the changes to the database by invoking the SaveChanges method.
dbContext.Add(newCategory);
dbContext.Add(newCategory)
Loading Data
The following loading pattern from LINQ to SQL is not supported in Telerik Data Access.
var categories = dbContext.GetTable<Category>().ToList();
Dim categories = dbContext.GetTable(Of Category)().ToList()
Instead of this you should load data in Telerik Data Access in the following way:
var categories = dbContext.Categories.ToList();
Dim categories = dbContext.Categories.ToList()
Telerik Data Access supports LINQ queries. For more information, see How to: Query Data.