0

我有一些类的结构类似于下面显示的类。

[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;}
}

一切正常,除了附件类的列也将具有前缀。它的发生非常随机,因为有时它确实有前缀,有时却没有。

有什么方法可以防止附件有前缀,或者有更好的方法来构造我的类来防止这个问题。

4

1 回答 1

0

似乎方法是防止附件类上的嵌套前缀是直接连接请求和附件。仍然需要观察几次迭代。

[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;}

}
于 2012-12-05T05:04:11.887 回答