开发者

Silverlight+ WCF Ria Service + FK object member is marked with XmlIgnore, can I prevent this from being added to the generated file?

Using silverlight 4, with RIA Services Toolkit May 2010.

I have an Entity Data Model (.edmx) which contains a FK reference.

In my DomainContext Service class (which references my .edmx) I modified my GET method to include Include("FK_ENTITY_TABLE_NAME"):

public IQueryable<PARENT_ENTITY> GetPARENT_ENTITY()
{
    this.ObjectContext.PARENT_ENTITY.Include("FK_ENTITY_TABLE_NAME");
}

In my DomainContext Service Metadata class (.metadata.cs) named "internal sealed class PARENT_ENTITYMetadata" I added the [Include] attribute to the property which references my FK entity:

    [Include]
    public FK_ENTITY_TABLE_NAME { get; set; }

My generated (.g.cs) ria service proxy file contains the following DataContract with XmlIgnore:

private EntityRef<FK_ENTITY_TABLE_NAME_PARENT_ENTITY> _fk_entity_table_name;
public sealed p开发者_运维知识库artial class PARENT_ENTITY : Entity
{
...
        [Association("FK_ENTITY_TABLE_NAME_PARENT_ENTITY", "entity_id", ",entity_id", IsForeignKey=true)]
        [XmlIgnore()]
        public FK_ENTITY_TABLE_NAME FK_ENTITY_TABLE_NAME
        {
...

Therefore, when I use the XmlSerializer / DataContractSerializer and on my PARENT_ENTITY, it skips right over serializing my "FK_ENTITY_TABLE_NAME entity:

<PARENT_ENTITY>
(note: no FK_ENTITY_TABLE_NAME serialized here)
</PARENT_ENTITY>

Is there anything i can do to control the XmlIgnore attribute from being inserted in these generated files?


I'd suggest first off to fix your naming convention. Other than that make sure that you expose a get method for your DATA_ENTITY class so that it gets compiled into the generated code.

Also, why is your include for FK_ENTITY_TABLE_NAME but the entity class uses DATA_ENTITY? That seems strange to me. Is there any other relevant code you haven't included?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜