SQL Azure with LINQ

LINQ could be used with SQL Azure in the same way it is used with SQL Server. We are going to use School database again. So to see how we can use SQL Azure with LINQ

1. Create a console Appli8cation. For purpose of this walkthrough , I am creating Console app. You can use in same way in other managed application.

2. Right click on console application project. Select add new item and choose LINQ to SQL Class form Data tab.


3. Choose the option Server explorer and add a new connection. In Add new connection windows provide information for SQL Azure.


4. Now we need to write usual LINQ query to do CRUD operation against database in SQL Azure. Here I am fetching all the records from Person class


using System;
using System.Linq;

namespace LINQSQLAzure
 class Program
 static void Main(string[] args)
 DataClasses1DataContext context = new DataClasses1DataContext();
 var result = from r in context.Persons select r;
 foreach (var r in result)
 Console.WriteLine(r.LastName + " " + r.FirstName);

Expected output,


In this post , I explained LINQ with SQL Azure.

One response to “SQL Azure with LINQ”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com