This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have a database schema where there is a main entity that has several collections of other entities attached (one-to-many relationships). When I try to send this over the wire to a WCF service I get the following exception: Type 'Mindscape.LightSpeed.EntityCollection`1[[HawkModel.Attribute, HawkModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' is an invalid collection type since it has DataContractAttribute attribute. As far as I know I am not using anything where I defined the DataContractAttribute, and I'm having a bit of trouble finding where you are doing so. Is this a bug on my end or yours? This is in a test scenario wherein I have a basic console app that manually builds up a partial collection of bits and pieces and then calls teh service interface "save" method. If you need more details, I will be happy to provide them. Thanks, Dave |
|
|
An additional note. Digging around with Google I found the solution to be using the CollectionDataContractAttribute attribute rather than the DataContractAttribute attribute (don't you just love the redundant naming convention?). However, I don't think I have any control over that, at least not directly.
|
|
|
Ensure you are using the NetDataContractSerializer for any EntityCollections you are exposing - there is an attribute available in the Mindscape.LightSpeed.ServiceModel assembly to help with this and you can use it to decorate the applicable service operations. e.g: [ServiceContract] The impact of using this is that type information is sent along with the serialized data which allows it to be reconstructed at the other end correctly, given you are shipping EntityCollections you will have the LightSpeed assemblies at both ends so this isnt a problem and sounds like it is exactly what you want to do, but it would be a problem if you had ignorant external consumers. In those cases it would be better to deal in terms of arrays of objects which would probably push you more down a DTO mindset. Jeremy |
|
|
Thanks! That works like a charm. Can't wait for the documentation for this new, improved version of LightSpeed... |
|