asp.net mvc - MVC ViewModel - Need to define viewmodel -



asp.net mvc - MVC ViewModel - Need to define viewmodel -

i storing questionnaire in xml format string type info field called questionnaire. database fields contactid , questionannire. doing in mvc application.can tell me should viewmodel ?

the xml

<xml> <question>what country of origin?/<question> <answer>united kingdom </answer> <question>what place of birth?</question> <answer>united states </answer> </xml>

your viewmodel this:

public class vm { public ienumerable<qa> myquestionsanswers {get;set; } } //then need qa class public class qa{ public list<string> questions {get;set;} public list<string> answers {get;set;} }

next need read xml , set list of qa...

xdocument document = xdocument.load(@"xmlfile1.xml"); var thequestions = (from br in document.descendants("questions") select br).tolist(); var theanswers = (from or in document.descendants("answers") select or).tolist(); var myqa = new qa{questions=thequestions, answers=theanswers}

asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 model-view-controller asp.net-mvc-viewmodel

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -