This project is read-only.

Databinding with database?

Nov 25, 2009 at 9:17 PM

Hello,

First, congratulations for this impressive project!

But is it currently possible to bind database data using the MForm framework?

Thanks in advance,

Arnaud

Dec 7, 2009 at 10:18 AM

Well, the idea of MForm is to simply generate forms from hierarchial data models. The (relational) database uses a relational data model and these two models do not map well. In my opinion the library with custom web controls is not the greatest place to define such a mapping.

Currently only xml data can be bound to MForm, the development effort is going in the direction of supporting xml serializable objects to be bound (currently this is possible indirectly and in a limited manner by serializing/deserializing objects externally using XmlSerializer). When the latter is done, I believe that binding database data could be done using some ORM tool like Entity Framework or NHibernate.

The other way of binding MForm with database data would be by using XML Support in Microsoft SQL Server 2005 (http://msdn.microsoft.com/en-us/library/ms345117(SQL.90).aspx), especially using the FOR XML query might be useful.

First you would need to obtain xml schema of SQL->XML, that could be used to generate the MForm form.

Then you would have to create an sql query that would return xml that would be bound to MForm.

When MForm is changed, another query would have to update the database with the Xml out of MForm. It would be up to you how to keep the data in the database:

Of course this is not an out of the box solution. Please let me know if you decide to follow the path. I would be most glad if you wanted to write in the way to isolate your business code from the MForm(Xml) <-> Sql wrapper code.