user - In controller part ASP.NET MVC 4 Survey project -


in code below have problem:

    list<surveycontext> surveys = (from s in dbcontext.surveys                                    s.username == s.username                                     select s.id).tolist();     if(surveys.count() > 0)                 {                    int id = 0;                    int.tryparse(surveys.first(), id);                    return id;                  }                  return 0; 

error : tolist()

error 1 local variable named 's' cannot declared in scope because give different meaning 's', used in 'parent or current' scope denote else

and here: int.tryparse(surveys.first(), id); name 'surveys' not exist in current context name exist in context... can me??

error 1

use == instead of =

where s.username == username 

error 2

try naming s variable on linq query in different way, maybe su or survey. seems me error on code you're not showing.

list<surveycontext> surveys = (from su in dbcontext.surveys                                su.username == su.username                                 select su.id).tolist(); 

error 3

i think meant surveys instead of surveys , need use out when passing idparam

int.tryparse(surveys.first(), out id); 

and since you're not evaluating parse result i'd should use int.parse

id = int.parse(surveys.first()); 

and have use property of survey, you're trying convert entire survey instance int

id = int.parse(surveys.first().property); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -