c# - Return list of string -


i need modify method mentioned below return list of strings . take contactid input , should return list of questionnaires

public string getfatcaquestionnaire(int contactid, string questionnairetype) {     using (var context = new dbdealingcontainer())     {         if (context.connection.state == connectionstate.closed)             context.connection.open();          var fatcaquestionaires = context.fatcaquestionaires.firstordefault(p => p.contactid == contactid && p.questionnairetype == questionnairetype);         return fatcaquestionaires != null ? fatcaquestionaires.questionaire : null;     } } 

new proposed method

public list<string> getfatcaquestionnaire(int contactid) {     using (var context = new dbdealingcontainer())     {         if (context.connection.state == connectionstate.closed)             context.connection.open();          var fatcaquestionaires = context.fatcaquestionaires.select(p => p.contactid == contactid).tolist();         return fatcaquestionaires.tolist();         //return fatcaquestionaires.tolist() != null ? fatcaquestionaires : null;     } } 

actually need return list of fatcaquestonaires. questionaire , not whole fatcaquestonaires object. 1 tell me how go it.

project out property want .select(x => x.myprop);

return fatcaquestionaires.select(x => x.questionaire).tolist(); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -