The Rapid Entity Framework Mapping is very straight forward. I will be explaining the basic mapping attributes that will get you giong here. First of all, to map classes as entities, you need to reference the PersistentFramework.dll file into your project, and make a using statement in to PersistentFramework.Mapping.

The following are the mapping attributes and their usage :
  • Entity("TableName") : For a class to become queryable by the Rapid Entity Framework, it has to be marked with Entity attribute which takes a single parameter of the underlying database table that this entity is mapped to.
  • DiscriminatorValue("Discriminator", "NonPerishable") : This is an class level mapping for entities that are subclass of another entity. This is refered to a single table relationship. Entities that are marked with discriminator attribute has a base entity which is mapped to the table. The discriminator attribute takes two values: the column name for discriminating the entity from the others that share the same base, and the value that identifies what subclass the entity is. see Discriminatory Relationship for more details.
  • Field("column", false, true) : This is the most simplest amongst the mapping attribute, because it maps one to one with your table. You can map the column of your table to a property of your entity class using the Field Attribute. The first parameter is the column name, which you are mapping to, the second parameter means is the column a Primary Key Column. The last one means if the column allows null value. This is simple and here is a simple usage :

[Field("Country", false, true)]
  • Key("column") : The Key attribute has a property called "AutoKey" which is defaulted to false. when set to true, means the key is automatically generated by your database engine. an example of primary key attribute is following :

[Key("Id", AutoKey = true)]
  • Composite Keys More than one Key attributes will be regarded as a composite key by rapid.

Last edited Feb 23, 2010 at 1:59 PM by ahmedsalako, version 14


No comments yet.