Question

I have a few classes structured similar to those shown below.

[ActiveRecord]
public class Request : ActiveRecordBase
{
    [PrimaryKey]
    public int Id {get; set;}

    [Nested("SectionA")]
    public SectionA A {get; set;}

    [Nested("SectionB")]
    public SectionB B {get; set;}

}

public class SectionA
{
    [Property]
    public string Description {get; set;}

    [Property]
    public string Remark {get; set;}

    [HasMany(typeof(Attachment), 
             Table="Attachments", ColumnKey="RequestId",
             Where="Section = 'SectionA'")]
    public IList Attachments {get; set;}
}

public class SectionB
{
    [Property]
    public string Description {get; set;}

    [HasMany(typeof(Attachment), 
             Table="Attachments", ColumnKey="RequestId",
             Where="Section = 'SectionB'")]
    public IList Attachments {get; set;}

}

[ActiveRecord]
public class Attachment
{
    [PrimaryKey]
    public int Id {get; set;}

    [BelongsTo("RequestId")]
    public Request Owner {get; set;}

    [Property]
    public string Section {get; set;}

    [Property]
    public string FilePath {get; set;}
}

Everything works fine, except that the columns for Attachment Class will have the prefix as well. And it happens quite randomly, as in some time it does have the prefix and sometime it doesn't.

Is there any way to prevent the Attachment from having the prefix, or is there a better way to structure my classes that prevent this issues.

Was it helpful?

Solution

Seems like way is prevent the nested prefix on Attachment class is to connect Request & Attachment directly. Still need to observe for a few iteration.

[ActiveRecord]
public class Request : ActiveRecordBase
{
    [PrimaryKey]
    public int Id {get; set;}

    [HasMany(typeof(Attachment)]
    public IList Attachments {get; set;}

    [Nested("SectionA")]
    public SectionA A {get; set;}

    [Nested("SectionB")]
    public SectionB B {get; set;}

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top