Data model creation

Modified on 2010/08/30 20:01 by IT — Categorized as: Uncategorized

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:


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; }