Dynamic property list

Dynamic property list

Old forum URL: forums.lhotka.net/forums/t/4035.aspx


JeffS posted on Thursday, December 13, 2007

Let me start by stating that I am new to object oriented programming and have only started to scratch the surface of custom frameworks and design patterns.  We have a thick client thick using win forms and a website using ASP.net, both application utilize a web service, SQL Sever 2005 and C#. I am tasked with creating business objects that bind to custom controls and move away from link everything with a datasets.   The columns/fields returned from the database can change at runtime and I need a business object that can change its properties based on the data.  The DBA can ensure that fields in the database use standard names so that I can coded against field names. However the DBA can’t predict what field will be in the staging database at any given time, and it might even change in a session.   The data does not require editing, this application only display data collected from outside sources.

 

In the past I would use look up tables to supply data validation, business rules, formatting information, and captions for each field in the database but I’m ready to find something better.  I prefer to be able to display data based on user profiles and the current schema.

 

So fare I researched data driven object factories and data mapping frameworks but it did not find anything that addressed the dynamic properties with good examples. I’m really impressed with the Expert C# 2005 Business Objects book and would love to apply the CLAS.Net frame work so that I can provide serialized object from the web serves but I’m not sure how to build create the properties list.  If anyone has suggestions please let me know.

 

Thank you,

 

Jeff

DavidDilworth replied on Friday, December 14, 2007

We have BOs that have "Dynamic Attributes" that are decided at runtime not development time.

We had to write our own mini-framework to handle these Dynamic Attributes.  So we have classes that "understand" a boolean value, an item from a dropdown list, a number - those kinds of things.   And we have supporting UI code that knows how to take a Dynamic Attribute and render it into a valid UI control with the correct value.  And then get the values back from it afterwards to do a Save().

It's not trivial to get it all working and you'll need to use a fair amount of reflection-based code to determine types dynamically at runtime.

But if you really need a truly flexible BO, then it's probably your only option.

Copyright (c) Marimer LLC