XmlSerialize中的循环引用

| 我正在使用T4文本模板生成DTO POCO,以用于我的NHibernate域模型。 这些POCO将使用ASMX Web服务(与Mono兼容)发送到客户端,但是如果我不将“ 1”属性设为“ 0”,我将遇到一个循环引用。 有什么方法可以创建POCO,以使循环引用仍然存在于客户端,但是当通过Web服务传递时,该引用将被忽略。 也许是定制的
XmlSerializer
?在Mono上使用WCF的支持不够。
public partial class UserDTO
{

    public System.Guid ID
    {
        get;
        set;
    }

    public System.String Username
    {
        get;
        set;
    }

    public System.String Password
    {
        get;
        set;
    }
    [XmlIgnore]
    public List<InspectionDTO> Inspections
    {
        get;
        //internal set;
        set;
    }

    public ContactDTO Contact
    {
        get;
        set;
    }

    public OrganisationDTO Organisation
    {
        get;
        set;
    }
    [XmlIgnore]
    public List<RoleDTO> Roles
    {
        get;
        //internal set;
        set;
    }
}


public partial class ContactDTO
{

    public System.Guid ID
    {
        get;
        set;
    }

    public System.String FirstName
    {
        get;
        set;
    }

    public System.String LastName
    {
        get;
        set;
    }
    [XmlIgnore]
    public List<AddressDTO> Addresses
    {
        get;
        //internal set;
        set;
    }
    [XmlIgnore]
    public List<EmailDTO> Emails
    {
        get;
        //internal set;
        set;
    }
    [XmlIgnore]
    public List<UserDTO> Users
    {
        get;
        //internal set;
        set;
    }
    [XmlIgnore]
    public List<PhoneDTO> Phones
    {
        get;
        //internal set;
        set;
    }
}
    
已邀请:

要回复问题请先登录注册