We have XML code stored in a single relational database field to get around the Entity / Attribute / Value database issues, however I don't want this to ruin my Domain Modeling, DTO, and Repository sunshine. I cannot get around the EAV/CR content, but I can choose how to store it. Question is how would I use it?
How could I turn the XML metadata in to a class / object at run time in C#?
For example:
XML would describe that we have a food recipe which has various attributes, but usually similar, and one or more attributes about making the food. The food itself can literally be anything and have any type of crazy preparation. All attributes are searched and may link to existing nutritional information.
// <-- [Model validation annotation goes here for MVC2]
public class Pizza {
public string kind {get; set;}
public string shape {get; set;}
public string city {get; set;}
...
}
and in the ActionMethod:
makePizzaActionMethod (Pizza myPizza) {
if (myPizza.isValid() ) { // this is probably ModelState.isValid()...
myRecipeRepository.Save( myPizza);
return View("Saved");
}
else
return View();
}