With the Q1 release of Telerik OpenAccess ORM, Telerik released a brand new LINQ Implementation and supporting Visual Entity Designer. I have shown in this blog how to connect to SQL Server, MySQL, and how to use the new LINQ with RIA Services. Today I will show you how to connect to SQL Azrue.
To get started, we have to create a new Telerik Domain Model in the server (ASP.NET) project. We’ll create a new Domain Model by right clicking on the server project and selecting “Add” and choosing the Telerik Domain Model from the menu.
In the dialog presented by OpenAccess select the database you want to connect to, for this project choose Microsoft SQL Azure. You also have to manually put in the connection string to SQL Azure in the format of:
Next you have to map your tables to entities. The easiest thing to do is just map all of your tables by selecting the checkbox next to “Tables” in the Choose Database Items dialog and pressing the Finish button.
Visual Studio adds a new Telerik Domain Model to your project.
Now you are free to use the LINQ implementation to build your application. For simplicity, I will drag a gridView control onto the form and then use LINQ to bind all the customers in Germany. The code is here:
1: protected void Page_Load(object sender, EventArgs e)
3: if (IsPostBack==false)
5: //data context
6: NorthwindEntityDiagrams dat = new NorthwindEntityDiagrams();
7: //LINQ Statement
8: var result = from c in dat.Customers
9: where c.Country == "Germany"
10: orderby c.CustomerID
11: select c;
12: //Databind to the ASP.NET GridView
13: GridView1.DataSource = result;
The results are show here.
Page rendered at Thursday, August 18, 2022 7:02:12 AM (Eastern Daylight Time, UTC-04:00)
The opinions expressed herein are my own personal opinions and do not represent
my employer's view in anyway.