Persistent Ignorance

Meta programming requires that we annotate or tag extraction points (another form of data) with metadata, these extraction points are then extracted using a domain dsl tool that understands the metadata. Meta programming is a concept used by Rapid entity framework and many other ORMs, it is used at the level of inspecting domain artifacts (In our case, entities) and extracting data based on known facts.

In ORM, metadata or tags can be analogous to .net attributes , xml configurations , assembly, embbedded resources, xml, comments or coding convention (To name a few). Rapid entity framework brings persistent ignorance to your plates using industry defined/desired ORM persistent ignorance methodologies.

List of persistent ignorance

1. Xml Mapping
2. Interface based Entity (with xml or attribute mapping)
3. Convetion ? (Still looking at the best ways)

1. XML Mapping

Rapid now comes with full xml mapping strategies, which will make sure entities metadata's are seperated from entity. We have various flavours of mapping object to tables in rapid entity framework, and XML mapping is one of them. To map an entity to table using xml, you will have to either use the rapid entity designer (Integrated in VS2010) or you can code it by hand.

The following is an example of the XML mapping:
<?xml version="1.0" encoding="utf-8"?>
<xml-entity-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://rql-rapid.org">
  <table-name>Customers</table-name>
  <class>Customer</class>
  <assembly-name>NorthWind</assembly-name>
  <keys>
    <key priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="CustomerID" class-property="CustomerID" />
  </keys>
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="CompanyName" class-property="CompanyName" />
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="ContactName" class-property="ContactName" />
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="ContactTitle" class-property="ContactTitle" />
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="Address" class-property="Address" />
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="City" class-property="City" />
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="Region" class-property="Region" />
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="PostalCode" class-property="PostalCode" />
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="Country" class-property="Country" />
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="Phone" class-property="Phone" />
  <field priority="0" allow-null="false" is-auto-key="false" is-unique="false" name="Fax" class-property="Fax" />
  <one-to-ones />
  <many-to-ones />
  <one-to-manys>
    <one-to-many class-property="Orders" relation-class="Order">
      <join-column>CustomerID</join-column>
      <relation-column>CustomerID</relation-column>
    </one-to-many>
  </one-to-manys>
</xml-entity-mapping>

Last edited Mar 21, 2011 at 12:12 PM by ahmedsalako, version 3

Comments

No comments yet.