We have XML code stored in one field of a relational database to get around Entity / Attribute / Value entity problems, however I don't want this to destroy the sunshine of domain modeling, DTO and repository. I cannot get around the EAV / CR content, but I can choose how to save it. The question is, how can I use it?
How can I turn XML metadata into a class / object at runtime in C #?
For instance:
XML will describe that we have a food recipe that has various attributes, but is usually similar, and one or more cooking attributes. The food itself can literally be anything and have any crazy preparation. All attributes are viewable and can link to existing nutritional information.
public class Pizza {
public string kind {get; set;}
public string shape {get; set;}
public string city {get; set;}
...
}
and in ActionMethod:
makePizzaActionMethod (Pizza myPizza) {
if (myPizza.isValid() ) { // this is probably ModelState.isValid()...
myRecipeRepository.Save( myPizza);
return View("Saved");
}
else
return View();
}