Dynamic Data architecture and LlblgenPro integration

Posts   
 
    
Walter Almeida avatar
Posts: 150
Joined: 27-Aug-2007
# Posted on: 23-Jul-2008 18:53:23   

Hello,

I have seen the announcement of integration of Llblgen with the new MS Dynamic Data feature. There is something I must have missed regarding Dynamic Data but to be honest I haven’t read too much yet about it… But my understanding was that ASP.NET controls, through Dynamic Data, are able to leverage attributes set on the entity model to perform automatic validation, select what template or control to use for rendering specific fields etc… So if this is the way it work, my understanding is that all that you need on your model to have it work is having the proper attributes applied to the fields of your entities on your model. So that means for Llblgen pro only an update of the code generation templates to include the generation of the correct attributes on the entities fields, to enable use this entity model to leverage the Dynamic Data features. Attributes being generated relevant to the data model constraints or maybe even further customizable though a plugin to the Llblgen designer.

But for what I’ve read, I seen that you had to meet and talk with Microsoft so that MS could enable other mapper than Linq to Sql to be compatible with Dynamic Data. Why?? I guess I must have missed something: is there something more than adding attributes to the model to make it usable with Dynamic Data?

Is it that Dynamic Data was first thought as only working when used with Link to SQL and no more? And therefore would not work by just data-binding an object model with proper attributes set to a grid or other control? Which would seem a little bit constraining to me…

The point I want to get at is the following: I am building a smart app using Windows Forms (and Llblgen for the O/R Mapping tool) and it was on my plan to customize LlblgenPro templates to add attributes to my fields. I wanted then to create my custom controls that would leverage these attributes to provide automatic validation. And then I saw this whole Dynamic Data fuzz and it’s integration with LlblgenPro and thought: Hey! That’s what I need! And even though Dynamic Data is not planned yet on Windows Forms, I though I then could still leverage the use of Dynamic Data attribute my own way… If already included in the LlblgenPro preview of Dyanmic Data integration I then don’t even have to do the work of customizing the code generation templates ?

Any thoughts on this?

Kind Regards Walter Almeida

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 01-Aug-2008 11:33:53   

Walter wrote:

Hello,

I have seen the announcement of integration of Llblgen with the new MS Dynamic Data feature. There is something I must have missed regarding Dynamic Data but to be honest I haven’t read too much yet about it… But my understanding was that ASP.NET controls, through Dynamic Data, are able to leverage attributes set on the entity model to perform automatic validation, select what template or control to use for rendering specific fields etc… So if this is the way it work, my understanding is that all that you need on your model to have it work is having the proper attributes applied to the fields of your entities on your model. So that means for Llblgen pro only an update of the code generation templates to include the generation of the correct attributes on the entities fields, to enable use this entity model to leverage the Dynamic Data features. Attributes being generated relevant to the data model constraints or maybe even further customizable though a plugin to the Llblgen designer.

The attributes have to be added onto special meta classes, outside the domain classes, so you don't need to update anything simple_smile You can just grab a generated code assembly and build the validation as you want, and together with that the special look/feel you want per entity field, e.g. which control to use.

But for what I’ve read, I seen that you had to meet and talk with Microsoft so that MS could enable other mapper than Linq to Sql to be compatible with Dynamic Data. Why?? I guess I must have missed something: is there something more than adding attributes to the model to make it usable with Dynamic Data?

Yes, dynamic data builds the pages, the search pages and also calls the underlying datasource controls to update rows in the forms. So if there wouldn't have been any openness from their part, it wouldn't be possible to use it with something else besides linq to sql or entity framework.

Is it that Dynamic Data was first thought as only working when used with Link to SQL and no more? And therefore would not work by just data-binding an object model with proper attributes set to a grid or other control? Which would seem a little bit constraining to me…

The whole point of dynamic data is that it builds the pages from meta-data retrieved from the model it has to work with. But it has to retrieve that meta data using a uniform way, otherwise it's tied to a select group of mappers. So to be able to use dynamic data with another mapper, like llblgen pro, the model data reader, the ability to save data etc. had to be standarized. That's done by MS now. So you can use any o/r mapper with dynamic data now. The advantage of that is that users of LLBLGen Pro can use dynamic data to prototype sites and use it as a way to build an editor real fast on a database with the toolset they already know.

The point I want to get at is the following: I am building a smart app using Windows Forms (and Llblgen for the O/R Mapping tool) and it was on my plan to customize LlblgenPro templates to add attributes to my fields. I wanted then to create my custom controls that would leverage these attributes to provide automatic validation. And then I saw this whole Dynamic Data fuzz and it’s integration with LlblgenPro and thought: Hey! That’s what I need! And even though Dynamic Data is not planned yet on Windows Forms, I though I then could still leverage the use of Dynamic Data attribute my own way… If already included in the LlblgenPro preview of Dyanmic Data integration I then don’t even have to do the work of customizing the code generation templates ?

The validation, which controls are used etc. is written in small classes which are just there to specify the validation per entity field, the layout for the controls of taht entity field etc. So you could use that in your winforms app as well indeed. The designer doesn't offer that much in that area other than custom properties which you can use at generation time to produce these classes for you. It could be a good way to do it that way as you then can store the meta-data to produce these attribute classes with the project so you don't get things going out of sync with each other.

Frans Bouma | Lead developer LLBLGen Pro
Walter Almeida avatar
Posts: 150
Joined: 27-Aug-2007
# Posted on: 04-Aug-2008 14:18:27   

Hello Frans, Thank you for your answer. I have a few more questions:

The attributes have to be added onto special meta classes, outside the domain classes, so you don't need to update anything You can just grab a generated code assembly and build the validation as you want, and together with that the special look/feel you want per entity field, e.g. which control to use.

So the preview of Dynamic Data for Llblgen is including the templates for generating these special metadata classes?

The advantage of that is that users of LLBLGen Pro can use dynamic data to prototype sites and use it as a way to build an editor real fast on a database with the toolset they already know.

You're talking about prototype sites. Do you see Dynamic Data as a RAD prototyping technology not fitting for larger developments?

The validation, which controls are used etc. is written in small classes which are just there to specify the validation per entity field, the layout for the controls of taht entity field etc. So you could use that in your winforms app as well indeed.

And these small classes can be generated by Llblgen as part of the model? Already done in the templates of Dynamic Data preview?

Thank you Kind Regards Walter Almeida

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 04-Aug-2008 16:12:27   

Walter wrote:

Hello Frans, Thank you for your answer. I have a few more questions:

The attributes have to be added onto special meta classes, outside the domain classes, so you don't need to update anything You can just grab a generated code assembly and build the validation as you want, and together with that the special look/feel you want per entity field, e.g. which control to use.

So the preview of Dynamic Data for Llblgen is including the templates for generating these special metadata classes?

No, it includes a compiled assembly which is used by the DynamicData runtime of MS to produce entity meta data. This is possible as all the meta-data necessary is already in the generated code simple_smile

The advantage of that is that users of LLBLGen Pro can use dynamic data to prototype sites and use it as a way to build an editor real fast on a database with the toolset they already know.

You're talking about prototype sites. Do you see Dynamic Data as a RAD prototyping technology not fitting for larger developments?

Personally I don't think 'RAD' is something one should use for production systems, but it could be useful in small apps or for parts of applications which require GUIs which can be produced from meta-data from the model.

GUI's which have to be ergonomically useful are better off being hand-designed.

The validation, which controls are used etc. is written in small classes which are just there to specify the validation per entity field, the layout for the controls of taht entity field etc. So you could use that in your winforms app as well indeed.

And these small classes can be generated by Llblgen as part of the model? Already done in the templates of Dynamic Data preview? Thank you Kind Regards Walter Almeida

No, these aren't generated, in fact NOTHING is generated simple_smile You start with a web template in VS.NET and use an assembly together with the generated code and start from there.

Frans Bouma | Lead developer LLBLGen Pro
Walter Almeida avatar
Posts: 150
Joined: 27-Aug-2007
# Posted on: 04-Aug-2008 16:26:58   

Ok Frans, Thanks again for your answers. I think I should now try by myself and see what's involvedsimple_smile

Regards Walter Almeida

johnman
User
Posts: 10
Joined: 11-Mar-2007
# Posted on: 12-Sep-2008 01:17:04   

Hi,

Will there be a section for dynamic data? Might help people when it comes to checking for answers and posting new questions.

I have a question with regards to extending the dynamic data site (i.e. how fields are rendered etc).

Watching some videos from Scott Hanselman it looks like I have to do something like:

[MetadataType(typeof(AddressEntityMetadata))]
    public partial class AddressEntity
    {
    }

    public class AddressEntityMetadata
    {
        [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}")]
        public object LastModified { get; set; }
    }

I added this as AddressEntityMetadata.cs in the DatabaseGeneric\EntityClasses folder (alongside my AddressEntity.cs class which maps onto the Address table in my database).

This should format my date but doesn't appear to. Is there a different approach I should try (or should the .cs file be somewhere else...a different project?).

Thanks

John

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 12-Sep-2008 11:31:35   

I'm not sure but I think the metadata class should be in the dynamic data vs.net project.

Frans Bouma | Lead developer LLBLGen Pro
johnman
User
Posts: 10
Joined: 11-Mar-2007
# Posted on: 12-Sep-2008 13:18:14   

Otis wrote:

I'm not sure but I think the metadata class should be in the dynamic data vs.net project.

Hi,

Do you mean the ASP.NET Dynamic Data Website? I tried that but then the page wouldn't load said that there was an error (sorry don't have it with me now).

I tried having the class within the site using the same namespace as the site (even tried keeping the namespace the same as the actual Entity Class assembly).

Neither seemed to work.

Any ideas?

johnman
User
Posts: 10
Joined: 11-Mar-2007
# Posted on: 12-Sep-2008 23:46:54   

johnman wrote:

Otis wrote:

I'm not sure but I think the metadata class should be in the dynamic data vs.net project.

Hi,

Do you mean the ASP.NET Dynamic Data Website? I tried that but then the page wouldn't load said that there was an error (sorry don't have it with me now).

I tried having the class within the site using the same namespace as the site (even tried keeping the namespace the same as the actual Entity Class assembly).

Neither seemed to work.

Any ideas?

My Bad. Namespace didn't match the AddressEntity namespace which was why the changes didn't seem to be picked up. Still no success having the class in the project but having the partial class in the LLBLGen Pro generated project seems to work.