Follow us

Tuesday, December 6, 2011

LINQ to SQL #2 : Overviewing DBML file.

First of all, we need to add a DBML (Database Markup Language) file. DBML file, .dbml, can de added as follows:

  1. Right click on Application's Root and select Add New Item. Add New Item option box will be opened.
  2. Select LINQ to SQL Classes (Visual C#) and provide the relevant name. In our case, its Technoscatter.dbml

    Technoscatter.dbml

  3. Click on Add.

    Along with Technoscatter.dbml, two other files will be created in the App_Code folder under Technoscatter.dbml file :

    • Technoscatter.dbml.layout
    • Technoscatter.designer.cs

  4. Object Relational Designer will be opened. You can now create Data Classes and Methods by dragging it from Server Explorer.

    In our case, we have added, two tables, namely, Members and Organisations and two Stored Procedures, namely, AddAndUpdateMembershipDetails and CheckIfOrganisationExists

    Note: Shortcut for viewing Server Explorer is Ctrl+W, L

  5. Save and Exit the file.

Created DBML file will look like as shown below:

LINQ to SQL design Surface

Concept of *.dbml.layout file

Technoscatter.dbml.layout

.dbml.layout file is just to show you how your model classes are laid out in the designer. I don't believe it has any information about the actual schema etc.

Concept of *.designer.cs file

Technoscatter.designer.cs

.designer.cs file contains DataContext class and the classes for tables, views and Stored Procedures. For example, in our case, Technoscatter.designer.cs contains the following classes:

  • TechnoscatterDataContext
  • Organisation
  • Member
  • AddAndUpdateMembershipDetailsResult
  • CheckIfOrganisationExistsResult

Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments: on "LINQ to SQL #2 : Overviewing DBML file."

Post a Comment