c# - Rule-based available values for a property within model -


i have question regarding put available values of specific property within model class. imagine have model class has 2 properties family , series possible values of series property depends on value of family property.

the business logic contains set of rules defines series values available due value specified family property. model should have valid state, means if value of family property changes , available values of series property change, value of series property must changed 1 of available values fit valid state.

my intention display available values within combobox both family property , series property. @ moment i'm not sure whether put available values of series property

  1. into viewmodel,
  2. into model,
  3. or introduce separate layer between viewmodel , model covers data validation , functionality of providing available values specific properties within model (that acts plain data container).

i tend use second or third approach (i prefer third approach) because of directly dependent values within model. example in fact simple. real problem covers 200 values available values of single property can depend on 5 or 10 other properties.

in addition, dependent values may not located within single model class , concerning model classes not know each other. possible values required available values property of model class can located within 2 or more other model classes.

what think best approach? there (better) way solve have not mention above?

thanks,

oliver

since stated model classes not know each other, should not create dependencies purpose of validation/aggregation/filtering (or whatever might call it) on such deep layer.

your requirements fit concerns of viewmodel cover value prepation among other things. on other hand, don't want rely on viewmodel doing validation given model always has in valid state. imagine might add client later uses model data can't use viewmodels.

therefore, additional "layer" or service might best option in opinion.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -