Business Logic Toolkit for .NET
www.bltoolkit.net
Welcome Guest, you are in: Login
|  Home   |  Download   |  Documentation   |  Discussions   |  Issues   |  License   |
RSS RSS

Navigation




Search the wiki
»

PoweredBy
To build Linq queries we need a data model as a set of classes describing the structure of the database tables and relations between the tables. Building such a model can be done in the following ways:

  • Using T4 Templates.
  • Using the special utility for generating classes for BLToolkit from Andrew Smirnov.
  • Using MyGeneration template from Andy77.
  • Using Linq to SQL data model designer.
  • Writing data model classes manually.

Let’s see how a data model class representing Category table from Microsoft’s Northwind database should look:

[TableName("Categories")]
public class Category
{
    [PrimaryKey, Identity] public int    CategoryID;
                           public string CategoryName;
    [Nullable]             public string Description;
    [Nullable]             public Binary Picture;

[Association(ThisKey="CategoryID", OtherKey="CategoryID")] public List<Product> Products; }
© 2010 www.bltoolkit.net