ASP Web Hosting | Windows Hosting Technology News

Creating LINQ to SQL 2008 Entities in C#

Posted on: July 20, 2009

Visual Studio.NET 2008 makes it very easy for us to create LINQ to SQL Entities using the Object Relational Designer. What it does is creates classes and methods that relate to the database columns and tables. This makes it possible for us to communicate with the data using LINQ (Language Integrated Query).

For this example, we will be using a SQL 2008 database with one table and three columns – id, name, and city.
Once we have our database set up, we will create a new class to represent the database table structure. It should look something like this:

using System;
using System.Data.Linq.Mapping;

public class people
[Column(IsPrimaryKey=true, IsDbGenerated=true)]
public int Id { get; set; }

public string name { get; set; }

public string city { get; set; }

public people()


It is advised to always include the table name in the class, although it is not really required if the class is named the same as the table in the SQL database.
Register the ASP.NET hosting plan with the latest SQL Server 2008 hosting from and receive reliable supports on the web hosting plan.


Leave a Reply

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

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

Google photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s

Follow SeekDotNet on Twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Web Hosting Categories

Top Clicks

  • None
July 2009
« Jun   Aug »
%d bloggers like this: