RelationalExplicitMapping class

Defines an explicit relationship mapping from one class to another for use by ObjectFactory, and when building Criterion objects for querying your database.

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

Syntax

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

Constructors

RelationalExplicitMapping(string name, Type subjectType, string localMemberName)
RelationalExplicitMapping(string name, Type subjectType, string localMemberName, string subjectMemberName)

Remarks

RelationalExplicitMapping is used if the name of the foreign key field/property on a data object does not match the primary key on the related class. This is generally a requirement where a single class has multiple foreign key relationships to another class.

The name specified for the RelationalExplicitMapping is also referred to when building Criterion queries for use with ObjectFactory retrieval operations.

Examples

[RelationalExplicitMapping("CurrentCompany", typeof(Company), "CurrentCompanyID")]
[RelationalExplicitMapping("PreviousCompany", typeof(Company), "PreviousCompanyID")]
public class Contact
{
    public int ContactID;

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

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

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

    [RelationalMemberInfo(IsIntZeroConvertedToNull = true)]
    public int PreviousCompanyID;
}
public class Company
{
    public int CompanyID;

    [RelationalMemberInfo(Length = 50)]
    public string CompanyName;
}