What are design patterns to support custom fields in an application?

后端 未结 7 1187
天命终不由人
天命终不由人 2020-11-30 16:37

We develop a commercial application. Our customers are asking for custom fields support. For instance, they want to add a field to the Customer form.

What are the kn

7条回答
  •  旧巷少年郎
    2020-11-30 17:23

    Something like Option 3 is the way to go and i have used this method previously. Create a single table to define additional properties and their corresponding values. This would be a 1-N relationship between your Customer and CustomerCustomField table (respectively). Your second question regarding defining relationships with custom properties would be something to think about. The first thing that comes to mind is adding a DataSource field, which would contain the table to which the property value is bound to. So essentially your CustomerCustomField would look like:

    1. CustomerId
    2. Property
    3. Value
    4. ValueDataSource (nullable)

    This should allow you to either bind to a specific data structure or simply allow you to specify unbound values. You can further normalize this model, but something like this could work and should be easy enough to handle in code.

提交回复
热议问题