New Posts New Posts RSS Feed: DataContract
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

DataContract

 Post Reply Post Reply
Author
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Topic: DataContract
    Posted: 20-Nov-2008 at 2:07pm
No, you can use the DataContractSerializer.  DCS recognizes older serialization attributes and interfaces, and since entities are marked Serializable and implement IXmlSerializable they can be serialized with DCS. 
 
You can mark any property with a serializable data type with the WebServiceVisible attribute.  Properties returning collections of related entities can be returned too.  In order to return the object graph though (eg, an order and its details), you also have to add the associated EntityRelationLinks to the EntitySerializationHelper.PublishRelationList, like so:
    EntitySerializationHelper.PublishRelationList(pm).AddRange(span.EntityRelationLinks);
 
The EntitySerializationHelper is intended for internal use only, and could be marked as internal in some future release (although there are no plans to do so right now).
Back to Top
jeffk View Drop Down
Newbie
Newbie
Avatar

Joined: 20-Nov-2008
Location: Atlanta
Posts: 4
Post Options Post Options   Quote jeffk Quote  Post ReplyReply Direct Link To This Post Posted: 20-Nov-2008 at 1:49pm
Thanks for the info Kim.  I have a few more questions.
 
Am I correct in understanding that I cannot use the DataContractSerializer?
 
Also, if I have created properties in my entity class (many which access other entities using entity relations), can these properties be serialized?  If so, what do I need to do for them?
 
 
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 20-Nov-2008 at 12:52pm
If you had an Enterprise license you would be able to open the Object Mapper and select a few options to expose your entities and selected properties.  Otherwise, you need to do the following:
 
For any Entity type to be exposed from the service:
 - Override the properties to be exposed
 - Mark these overridden properties with the [WebServiceVisbile] attribute
 
For example,
 
public sealed partial class Territory : TerritoryDataRow {
 
    [WebServiceVisible]
    public override long AreaId {
      get { return base.AreaId; }
      set { base.AreaId = value; }
    }
    [WebServiceVisible]
    public override string Description {
      get { return base.Description; }
      set { base.Description = value; }
    }
}
 
 
Back to Top
jeffk View Drop Down
Newbie
Newbie
Avatar

Joined: 20-Nov-2008
Location: Atlanta
Posts: 4
Post Options Post Options   Quote jeffk Quote  Post ReplyReply Direct Link To This Post Posted: 20-Nov-2008 at 11:54am
I have the DevForce professional license. 
 
Sorry it was unclear to me exactly what changes need to be made and where.  Are you saying I can just use the Ideablade attribute in my service definition or do I have do regenerate my model after adding additional attributes or both?
 
It would be very helpful if you could provide explicit directions for how to do this.
 
Thanks,
Jeff
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 20-Nov-2008 at 11:09am
Entity types in DevForce Classic are not decorated with DataContract and DataMember attributes, but are marked as Serializable and implement IXmlSerializable.   The newer attributes are not used because DevForce Classic still supports .NET 2.0+.  In order to use Entity types in a WCF service you need to mark the properties to be exposed with the IdeaBlade.Util.WebServiceVisible attribute. You can do this using the Object Mapper if you have an Enterprise license; if you don't have an Enterprise license, then it's a bit more work.
Back to Top
jeffk View Drop Down
Newbie
Newbie
Avatar

Joined: 20-Nov-2008
Location: Atlanta
Posts: 4
Post Options Post Options   Quote jeffk Quote  Post ReplyReply Direct Link To This Post Posted: 20-Nov-2008 at 6:11am
I have created a wcf data contract for a service I'm implementing and marked it up using the <DataContract> and <DataMember> attributes.
 
This all works fine for .net basic types like int, string, etc. but when I attempt to use a DevForce entity type the DataContractSerializer generates an error.
 
Is there something special I need to do to be able to use my entity types in Data Contracts?
 
Thanks,
Jeff
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down