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 Azure.
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,
3: if (IsPostBack==false)
6: NorthwindEntityDiagrams dat
= new NorthwindEntityDiagrams();
8: var result = from c in dat.Customers
9: where c.Country
11: select c;
to the ASP.NET GridView
The results are show here.
Stephen Forte sits on the board of several start-ups including Triton Works. Stephen is also the Microsoft Regional Director for the NY Metro region and speaks regularly at industry conferences around the world. He has written several books on application and database development including Programming SQL Server 2008 (MS Press).