Basic O/R Mapping

This part explain how to create a basic O/R Mapping. Lets to start with some simples tables in DB SQL SERVER 2000 or 2005, called "customer" and "sales_agent"


"Normal" use Custom Attributes and Reflection to work. To map our 2 tables to be used in Normal, we need to create a class like this, in this case in typed in C#:


Note that this class only have properties GET/SET, each one represent a column in our table and use Custom Attributes to discribe the table "customer" and "sales_agent" (TableName) and relate the property with column (ColumnName). Another pointing item is that the field "sales_agent_id" from table "customer" is a FOREIGN KEY from table "sales_agent", so this field has a type of class SalesAgent, in other words, the O/R mapping is so powerfull, allowing mapping of relationship between tables.

Last edited Nov 9, 2007 at 11:05 PM by fpeinado, version 39


No comments yet.