asp.net mvc - Next not looping in vb.net -
i have create function:
public shared function appid() dim appidq = v in db_apps.app_users v.nt_id = system.environment.username select v each v in appidq return convert.toint32(v.app_id) next v return appid() end function i trying return every app_id user place in viewdata (just testing placing info in cookie.) should returning 2 records, have 2 records meet criteria of query specified in appidq. upon debugging appidq indeed returning both records. when step little further "for each" doesn't loop although appidq returning 2 records function returning first record. appreciated.
update
obviously return appid() cause exit loop here new code:
public shared function appid() dim appidq = v in db_apps.app_users v.nt_id = system.environment.username select v each v in appidq dim var = v.app_id next v return appid() end function but still doesn't need to. need return results of
for each v in appidq dim var = v.app_id next v
as noticed return statement should moved after loop results.
public shared function appid() list(of int32) dim appidq = v in db_apps.app_users v.nt_id = system.environment.username select v dim result new list(of int32) each v in appidq result.add(convert.toint32(v.app_id)) next v return result end function edit
it seems comment need string representation of list. , when try tostring() extension, returns name of object (ex: system.collections.generic.list1[system.int32] don't know if there more efficient way, should work:
public shared function appid() string dim appidq = v in db_apps.app_users v.nt_id = system.environment.username select v 'create string representation dim stringlist new system.text.stringbuilder dim counter integer = 0 each v in appidq stringlist.append(v.app_id.tostring()) 'separator if not counter = appidq.count - 1 stringlist.append("; ") end if counter += 1 next return stringlist.tostring end function
Comments
Post a Comment