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.
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()
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.
In Telerik Data Access you can delete rows by invoking the Delete method of the OpenAccessContext, and passing the target object.
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.
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.
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.