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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -