| This tutorial was created with Visual Studio .NET 2008, | | | | Public Property name() As String |
| but can be recreated in 2005, after downloading and | | | | Get |
| installing Microsoft's LINQ Community Technology | | | | Return _name |
| Preview release, which can be downloaded from here. | | | | End Get |
| Visual Studio.NET 2008 makes it very easy for us to | | | | Set(ByVal value As String) |
| create LINQ to SQL Entities using the Object | | | | _name = value |
| Relational Designer. What it does is creates classes | | | | End Set |
| and methods that relate to the database columns and | | | | End 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 the | | | | Get |
| Designer and write the class ourselves, so that we get | | | | Return _city |
| a better understanding of what's going on. For this | | | | End Get |
| example, we will be using a SQL database with one | | | | Set(ByVal value As String) |
| table and three columns - id, name, and city. | | | | _city = value |
| Once we have our database set up, we will create a | | | | End Set |
| new class to represent the database table structure. It | | | | End Property |
| should look something like this: | | | | End Class |
| Imports System | | | | It is advised to always include the table name in the |
| Imports System.Data.Linq.Mapping | | | | class, although it is not really required if the class is |
| _ | | | | named the same as the table in the SQL database. |
| Public Class people | | | | You should always declare the Primary Key, especially |
| Private _Id As Integer | | | | if you are planning on making changes to the |
| Private _name As String | | | | database. IsDbGenerated is also used where the |
| Private _city As String | | | | database will auto-generate the values upon insert. |
| _ | | | | In the class, we need to define a [Column] for each in |
| Public Property Id() As Integer | | | | the database table, and then the name of the column |
| Get | | | | should be represented by the public string (or int, etc.) |
| Return _Id | | | | Next, we are going to display the data with a |
| End Get | | | | GridView, and we will also add a textbox and button |
| Set(ByVal value As Integer) | | | | to the page to allow searching of the database. |
| _Id = value | | | | Our ASPX page will look something like this: |
| End Set | | | | For the full article please visit Thanks and happy |
| End Property | | | | coding! |
| _ | | | | |