.NET
  Home arrow .NET arrow Page 3 - Beginning LINQ to SQL Using Visual Studio ...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Beginning LINQ to SQL Using Visual Studio 2008
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2008-03-31

    Table of Contents:
  • Beginning LINQ to SQL Using Visual Studio 2008
  • Developing a simple LINQ to SQL application (without LINQ designer): UI Design and source in VB.NET
  • Developing a simple LINQ to SQL application (without LINQ designer): source in C#
  • CRUD operations using the LINQ to SQL application (without LINQ designer): UI Design
  • CRUD operations using the LINQ to SQL application (without LINQ designer): Source in VB.NET
  • CRUD operations using the LINQ to SQL application (without LINQ designer): Source in C#

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Beginning LINQ to SQL Using Visual Studio 2008 - Developing a simple LINQ to SQL application (without LINQ designer): source in C#


    (Page 3 of 6 )


    To code in C#, follow the steps in the previous section with the following code (UI Design would be the same).

    The following is the "emp" class written in C#:


    using System.Data.Linq.Mapping;


    namespace SampleCS

    {

    [Table(Name="emp")]

    public class Emp

    {


    [Column(Name = "empno", IsPrimaryKey = true)]

    public Int32 empno { get; set; }


    [Column(Name = "ename")]

    public string ename { get; set; }


    [Column(Name = "sal")]

    public System.Nullable<double> sal { get; set; }

     

    [Column(Name = "deptno")]

    public System.Nullable<Int32> deptno { get; set; }


    }

    }


    The ASPX code would be the same as given in the previous section. The following is the code for code-behind (default.aspx.cs):


    using System.Data.Linq;


    namespace SampleCS

    {

    public partial class _Default : System.Web.UI.Page

    {


    protected void btnSelectStar_Click(object sender, EventArgs e)

    {

    DataContext db = new DataContext(new System.Data.SqlClient.SqlConnection("Data Source=.sql2k5;initial catalog=sample;user id=sa; password=eXpress2005"));

    Table<Emp> tblEmps = db.GetTable<Emp>();

    this.GridView1.DataSource = tblEmps;

    this.GridView1.DataBind();

    }

    }

    }


    More .NET Articles
    More By Jagadish Chaterjee


       · Hello guys,I am back with a series on "LINQ to SQL" using Visual Studio 2008. ...
       · WHat is that in new LINQ in VS2008.?Can any one explain it..............?
     

    .NET ARTICLES

    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries
    - Introducing LINQ to SQL Designer using Visua...
    - Beginning LINQ to SQL Using Visual Studio 20...
    - Coding an AjaxPro.NET Based Search Engine fo...
    - Building an AjaxPro.NET Based Search Engine ...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway