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
|
Hi, I can't find a way to get a Dynamic Data website to work with Entities that have value objects. When trying to insert a simple item with a value object, I receive this client-side javascript error: Error: Sys.WebForms.PageRequestManagerServerErrorException: Column 'PermissionRead' cannot be null The value object is: Permission { Read [bool] , Write [bool] } and it's attached to a "Role" Entity whose only attributes are "Name" and the value object above. There is no field on the insert web form that represents the value object so I can't assign it a value.
Thanks, Chris
|
|
|
You need to tell Dynamic Data how to render and edit your custom value object type. To do this, create field templates for viewing and editing the type, and annotate the property/properties with UIHintAttribute to connect it up to the field templates. I found http://rachelappel.com/asp-net-dynamic-data/custom-field-templates-in-asp-net-dynamic-data/ a helpful quick guide (she describes the process in terms of creating a custom template for the built-in integer type, but it appears to work for custom types too). |
|
|
Hi, |
|
|
LightSpeed is going to try to set the "Dimensions" property to an instance of the value object type. (We like value objects to be immutable, and even if they're not, dirty tracking would required us to replace the entire value rather than trying to change the properties of the existing value object instance.) So your extractor needs to insert a value object into the dictionary under the "Dimensions" key, e.g.: protected override void ExtractValues(IOrderedDictionary dictionary) |
|
|
Thanks for the explanation and example code. It was just what I needed. Custom objects seem to be working well in my DD website now :-) Chris |
|
|
... except for one little problem. I have a value object attached to an Entity. It displays and updates as expected through DD. Another Entity inherits (STI) from the first Entity but the value object does not display on the second Entity (on either list or edit views). I've only tried this through DD Futures rather than 3.5 SP1 RTM but let me know if you have trouble spotting the cause of the problem and I'll try to replicate it in DD 3.5 SP1 RTM. Thanks, Chris
|
|
|
This appears to be down to some sort of tort or malfeasance in Dynamic Data, specifically in the AssociatedMetadataTypeTypeDescriptionProvider. It seems that AMTTDP does not consider base class metadata when merging in the associated metadata. Therefore the derived entity type has no UIHint telling it what field template to use for the value object type, so DD silently just leaves it out. The solution is to associate each derived entity type with the base class metadata type (or, more robustly but more tediously, create a metadata type for each derived entity, and make this new metadata class derive from the base entity's metadata class). I'm not sure that there's anything we can readily do to automate this, without getting into a potentially complicated interaction with the AMTTDP. It seems like either a bug in the AMTTDP which should be fixed at that level, or a deliberate design decision which we probably shouldn't be trying to bypass! (Or it may just be because they were only thinking about LINQ to SQL and weren't considering derivation scenarios.) We'd welcome your feedback on this. |
|
|
Thanks for the reply Ivan. I've scoured the ASP.NET forums and found this post which implies that LightSpeed was already ahead of the curve with respect to supporting inheritence heirarchies. http://forums.asp.net/t/1314568.aspx Judging by the later posts, there might be changes in VS2010 that could fix this issue although since I still see the problem in DD Futures, I suspect there may need to be a few tweaks to the LS DD assembly to take advantage of the changes. If they are only thinking about L2S and EF then now is probably a good time for you to badger them about facilitating 3rd party ORMs, LS 3.0 deadlines permitting ;-) It would be nice if Mindscape could investigate this further when looking at the new features that will be available in VS2010 but I'm in no hurry since I'll have to find a workaround in the mean time anyway. I will just promote my value objects to Entities and take any performance hit that comes from extra DB queries. Hopefully with an eager load attribute set on the new association the impact should be negligible and I only have to get one affected value object working through Dynamic Data at launch so it's not too onerous a task :-) Thanks, Chris |
|