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 am trying to get a Dynamic Data web project to work with Lightspeed without having the Lightspeed model in the web project itself. I have been successful in referencing the data model and getting Dynamic Data to scaffold all the tables in the model. Where I am having my problem is trying to limit what tables are scaffolded. If I assign the ScaffoldTablle(true) attribute to the entity within the data model class then everything works fine. However, I want to assign the attribute in the DD project because ultimately I want to have multiple Dynamic Data projects for maintaining diferent groups of tables. So, I've created a partial class in the DD project with the ScaffoldTable(true) attribute but it doesn't work. Here's the class I created.
<ScaffoldTable( True)> _ I realize this is probably really a Dynamic Data issue but I've been unable to get a resultion going through the ASP.NET forums. Any help from this forum would be greatly appreciated. |
|
|
Partial class declarations are only merged within a project: if you create a Partial Class Member in your DD assembly, that's a completely separate class from the Partial Class Member in your model assembly. It sounds like what you want to do is "retrospectively" apply attributes to the classes in the model assembly, with the DD project deciding which classes get the ScaffoldTableAttribute. Is that correct? If so, you can't do this using compile-time constructs alone -- once you build the model assembly it is set in stone. Instead, what you need to do is use a type description provider to intercept DD's requests for attributes, and insert your own attributes at runtime. In some cases you can do this using DD's built-in "buddy classes" feature, but I don't think that will work in your case because it requires each model class to know about its "buddy class." So I think you will have to write your own specialised type description provider, by inheriting from TypeDescriptionProvider, overriding GetTypeDescriptor, and returning a custom descriptor class. This custom descriptor class will derive from CustomTypeDescriptor and override GetAttributes. To use your custom type description provider in DD, update your DD model registration to create your new class in the ContextConfiguration.MetadataProviderFactory: model.RegisterContext( |
|
|
Yes you are correct. I want to decide at runtime what tables and properties to use. Your proposed solution sounds involved but I'll give it a try. As an alternative, would you consider generating a custom type descriptor class like you describe that would allow enabling scaffolding for tables (and properties of a table) via properties? I would suggest setting all scaffolding to false as the default and then we'd enable only those we want. Thanks. |
|
|
I'll log a feature request for that, but it seems to be a specialised scenario, and something that customers can implement fairly easily themselves without requiring work in the LightSpeed DLLs themselves (and by doing so can tailor it to their specific needs instead of us trying to anticipate what any individual scenario might require). So it will be fairly low priority unless we hear other customers asking for it. Sorry. |
|