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
|
Hello, I've added an extended System.String property at the entity level with Name set to "PluralName", and I've added $entity.GetExtendedPropertyValue("PluralName") to my datacontracts.vm script. But when I try to run the model generator, I get a KeyNotFoundException on invocation of GetExtendedPropertyValue. I've tried this with different extended property names, and I get the same result. Any ideas?
|
|
|
This happens if the property is not set on the entity. You should either guard the GetExtendedPropertyValue call with a HasExtendedProperty call, or use the overload that takes a default (e.g. GetExtendedPropertyValue("PluralName", "Thingies")). See this post for more info. Also note that in current nightly builds Entity has a predefined PluralName property so you may experience clashes with that. (But on the plus side it may already do what you want, in which case you can get at it using $Inflector.Collection($entity).) |
|
|
Ivan, Thanks, it looks like I missed a couple of entites hiding in the outer reaches of my diagram. I have som eother questions. I'm trying to use these extended properties to customize serialization of DTO's for a RESTful service. I want to set the Order property on DataMember attributes so that the members are serialized in the correct order, but I'm not sure how to emit Order for things like foreign key fields (regular entity fields is easy using GetextendedPropertyValue and a custom Order property). Also Order is important because I believe you need it to properly deserialize if your xml is NOT in the correct order. Otherwise the deserialization may skip members if you don't list them alphabetically in you xml. Do you know a way around these DataContract issues? Maybe I should just go with the XmlSerializer. I'm wondering how other people deal with these issues. Thanks
|
|
|
Recent nightly builds support extension properties on one-to-many associations as well as entities and properties. An extension property defined on an association is available in the template on its collection, backreference and foreign key fields. So if you have a DtoOrder extension property you can just enable that extension for associations as well as properties, and you will then be able to request it on the FK field in the template (if it is set on the association of course). Regarding the underlying issue of element order in data contracts, I think this is a broader WCF issue and I am not sure what its status is. I have pinged Jeremy who is our WCF guru and asked him to jump in if he has any advice. |
|