2.5 WebServices and Custom Entity Code

Posts   
 
    
ronindm
User
Posts: 3
Joined: 28-Aug-2007
# Posted on: 28-Aug-2007 06:45:56   

Hello,

Previously in version 2.0 I added a readonly EntityCollection to an existing Entity for transmission through a WebService and once i added the TypeContainedAttribute it worked perfectly.

Today i upgraded to 2.5 and this code no loger serializes my custom entity property.


        [TypeContainedAttribute(typeof(ClientMenuGroupEntity))]
        public virtual EntityCollection<ClientMenuItemEntity> ActiveClientMenuItems
        {
            get
            {
                if (_activeClientMenuItems == null)
                {
                    _activeClientMenuItems = new EntityCollection<ClientMenuItemEntity>(EntityFactoryCache2.GetEntityFactory(typeof(ClientMenuItemEntity)));
                    _activeClientMenuItems.IsReadOnly = true;
                }
                return _activeClientMenuItems;
            }
}

Anyone have any ideas what i am doing wrong? (i am assuming its something i am doing as the way i understand it the serialization code was updated for 2.5?

thanks in advance, Dave

EDIT: my apologies for not reading the submission rules confused The error message received is a Null Reference exception inside the ORMSupportClasses. If i comment out my property above there is no error message.

I am using the SqlServer 2 class Adapter.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 28-Aug-2007 11:08:08   

Please check the following which is copied from LLBLGen Pro v.2.5 manual's section "Using the generated code -> Distributed Systems -> XML Webservices / WCF support":

Custom Member serialization/deserialization If you add your own member variables to entity classes including their properties, you probably also want these values to be serialized and deserialized into the XML stream. Normally, a custom member exposed as a read/write property is serialized as a string using the ToString() method of the value of the custom property. In a lot of cases this isn't sufficient and you want to perform your own custom xml serialization/deserialization on the value of this custom property, for example if this custom property represents a complex object. To signal that the LLBLGen Pro runtime framework has to call custom xml serialization code for a given property, the property has to be annotated with a CustomXmlSerializationAttribute attribute. When a property is seen with that attribute, LLBLGen Pro will call the entity method entity.PerformCustomXmlSerialization to produce valid XML for the custom property. Likewise, when deserializing an XML stream into entities, the LLBLGen Pro runtime framework will call, when it runs into a property annotated with a CustomXmlSerializationAttribute, the method entity.PerformCustomXmlDeserialization to deserialize the xml for the property into a valid object. You should override these methods in a partial class of the entity which contains the custom properties.

Custom property serialization/deserialization is a feature of the Compact25 xml format, which is used by Adapter in Webservices/WCF scenarios.

ronindm
User
Posts: 3
Joined: 28-Aug-2007
# Posted on: 28-Aug-2007 18:15:54   

Thanks a bunch, worked like a charm simple_smile

dave