vb.net - ID # being reset in ASP.NET -


in controller action attempting retrieve record db:

            dim surveydb = db.surveys.find(sid) 

where sid instantiated @ class level:

    private sid new integer 

when first create new survey (if surveydb nothing), add db , set sid so:

                db.surveys.add(survey)                 await db.savechangesasync()                 sid = survey.surveyid 

that seems go fine (say new survey goes row 20 survey.surveyid = 20), except if go page, sid getting reset reason, surveydb nothing.

why in asp.net class-level variable getting reset? how find record i'm looking for?

the code after if depends on result above line:

this should automatic (as far aware) when have await, when expression attempts use value should suspend until await finishes. important figure out before attempt solution 1 below.

otherwise....

one option wait complete (or number of them complete):

dim surveydb = db.surveys.findasync(sid)  task.whenall(surveydb)  if isnothing(surveydb.result)   //... else   //... end if 

this allow add number of async calls:

dim surveydb = db.surveys.findasync(sid) dim surveydb1 = db.surveys.findasync(sid1) dim surveydb2 = db.surveys.findasync(sid2)  task.whenall(surveydb, surveydb1, survyedb2)  if isnothing(surveydb.result)   //... else   //... end if 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -