Over a million developers have joined DZone.

Convert an Existing LINQ to SQL Model to Telerik OpenAccess in 30 Seconds

DZone's Guide to

Convert an Existing LINQ to SQL Model to Telerik OpenAccess in 30 Seconds

· Database Zone ·
Free Resource

Built by the engineers behind Netezza and the technology behind Amazon Redshift, AnzoGraph is a native, Massively Parallel Processing (MPP) distributed Graph OLAP (GOLAP) database that executes queries more than 100x faster than other vendors.  

If you are currently invested in LINQ to SQL and want to upgrade to Telerik OpenAccess ORM, with the new OpenAccess Q3 release you can do this quite easily. There is a new wizard included with OpenAccess that will automatically convert your LINQ to SQL classes to Telerik LINQ classes. Let’s take a look.

I’ll start with a simple project that has a simple LINQ to SQL model in it: Northwind.dbml. It is mapped to the Northwind database tables.


I created a simple web form that has a GridView on it. I decided that I would try to stump the wizard by writing a complex LINQ statement, one with aggregates, joins, sums, and projections to anonymous types. Then I take that code and bind it to the GridView. The LINQ code is shown here. 

NorthwindDataContext dat = new NorthwindDataContext();
//LINQ Query to Aggergate and Group by to an new type
var result = from i in
from c in dat.Customers
join o in dat.Orders
on c.CustomerID equals o.CustomerID
select new { c.Country, o.Freight }
group i by new { i.Country } into g
select new { g.Key.Country, TotalAmt = g.Sum(f => f.Freight) };

//bind the results
GridView1.DataSource = result;

Results are shown here:



Conversion time. Doing the convert is simple and done in place. Just right click on the LINQ to SQL model and choose “Convert From L2S Model to Domain Model” from the context menu.



This will bring up the OpenAccess Conversion wizard. In reality the wizard is one page. If you accept the defaults, the wizard will create a new RLINQ file (Telerik OpenAccess LINQ file) and give it the same Name and Namespace as the LINQ to SQL model. In addition, it will backup the old files.



Accepting all of the defaults and clicking next brings you to the confirmation page.



From here click Finish and the wizard will do its work. You will see a conversion report come up.



Now you will have a new OpenAccess Domain Model in your project.



Since your project now has two identically names LINQ classes, it is time to delete the LINQ to SQL class. (Don’t worry it is backed up.) Without changing any code in my application, I press F5 and the project runs, but now using Telerik OpenAccess.



Download AnzoGraph now and find out for yourself why it is acknowledged as the most complete all-in-one data warehouse for BI style and graph analytics.  


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}