Creating Linq to Sql Entities in Vb.net

This tutorial was created with Visual Studio .NET 2008,Public Property name() As String
but can be recreated in 2005, after downloading andGet
installing Microsoft's LINQ Community TechnologyReturn _name
Preview release, which can be downloaded from here.End Get
Visual Studio.NET 2008 makes it very easy for us toSet(ByVal value As String)
create LINQ to SQL Entities using the Object_name = value
Relational Designer. What it does is creates classesEnd Set
and methods that relate to the database columns andEnd Property
tables. This makes it possible for us to communicate_
with the data using LINQ (Language Integrated Query).Public Property city() As String
This tutorial will show how we can bypass theGet
Designer and write the class ourselves, so that we getReturn _city
a better understanding of what's going on. For thisEnd Get
example, we will be using a SQL database with oneSet(ByVal value As String)
table and three columns - id, name, and city._city = value
Once we have our database set up, we will create aEnd Set
new class to represent the database table structure. ItEnd Property
should look something like this:End Class
Imports SystemIt is advised to always include the table name in the
Imports System.Data.Linq.Mappingclass, although it is not really required if the class is
_named the same as the table in the SQL database.
Public Class peopleYou should always declare the Primary Key, especially
Private _Id As Integerif you are planning on making changes to the
Private _name As Stringdatabase. IsDbGenerated is also used where the
Private _city As Stringdatabase will auto-generate the values upon insert.
_In the class, we need to define a [Column] for each in
Public Property Id() As Integerthe database table, and then the name of the column
Getshould be represented by the public string (or int, etc.)
Return _IdNext, we are going to display the data with a
End GetGridView, and we will also add a textbox and button
Set(ByVal value As Integer)to the page to allow searching of the database.
_Id = valueOur ASPX page will look something like this:
End SetFor the full article please visit Thanks and happy
End Propertycoding!
_