开发者

Circular reference in XmlSerialize

I am using a T4 text template to generate DTO POCOs to use against my NHibernate domain model.

These POCOs are to be sent to the client using ASMX web services (To be compatible with Mono) but if I don't XmlIgnore the List<> properties I will run into a circular reference.

Is there any way to allow the POCOs to be created so that the circular reference still exists on the client side, but when passed through the Web service the reference is ignored.

Maybe a custom XmlSerializer? WCF is not supported enough on Mono to be used.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜