RelationalInfoAttribute class

Used to define options on a data object class to override default ObjectFactory behaviour.

Namespace: ReFlex.Data namespace
Assembly: ReFlex.Data.dll

Syntax

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class RelationalInfoAttribute : Attribute

Constructors

RelationalInfoAttribute();

Remarks

For example you might have a Contact class that comes from one database, and a Product class that comes from another database, using the RelationalInfoAttribute class you can define which connection string name to use for each of the classes.

You might also have a Product class for which data is sourced from a table named xyz_ProductStore, rather than the default behaviour tblProduct expected by ObjectFactory. Using RelationalInfoAttribute you can define that data should be retrieved from the table named xyz_ProductStore.

If the primary key field in your table does not match the [ClassName]ID format used by ObjectFactory (e.g. ProductID), you can also override this behaviour for a particular class using the RelationalInfoAttribute attribute.

Examples

[RelationalInfo(DefaultDatabaseOverride = "MyConnectionString"
    , DefaultIdentifierOverride = "MyContactID"
    , DefaultNameOverride = "xyz_ContactTable")]
public class Contact
{
    public int MyContactID;

    [RelationalMemberInfo(Length = 50)]
    public string FirstName;

    [RelationalMemberInfo(Length = 50)]
    public string LastName;

    [RelationalMemberInfo(IsIntZeroConvertedToNull = true)]
    public int CompanyID;

    public DateTime CreatedDate;
}