Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

Sequence and number of calls matters?

 CompositeKey ck = new CompositeKey(UserIDSID);

                UserProfileDataContext udc = new UserProfileDataContext();
                var results = udc.Users_get(ck.PrimaryID, ck.ServerID, CurrentUser.UserID, CurrentUser.UserSID);

                UserProfileDataContext udc2 = new UserProfileDataContext();             

                User = results.GetResult<Users_Get>().FirstOrDefault();
                ServiceList = results.GetResult<Users_Services>().ToList();
                CapacityList = results.GetResult<UserRole_DisplayResult>().ToList();
                AgentData = results.GetResult<AgentInfo>().FirstOrDefault();
                RolesList = results.GetResult<int>().ToList();
                AgentLicense = results.GetResult<License>().ToList();
                BrokerLicense = results.GetResult<License>().ToList();
                Insurance = results.GetResult<Insurance_GetResult>().ToList();
                MLSInfoList = results.GetResult<MLSInfo_GetResult>().ToList();
                ProfileList = results.GetResult<User_ProfileValidation_UpdateResult>().ToList();
                merchantStates = results.GetResult<MerchantStates>().ToList();

Open in new window


Consider this line towards the bottom of the code snippet:

merchantStates = results.GetResult<MerchantStates>().ToList();

merchantStates will have the correct number of entries.


However, if I run the following code, merchantSites does not have the correct data:

 CompositeKey ck = new CompositeKey(UserIDSID);

                UserProfileDataContext udc = new UserProfileDataContext();
                var results = udc.Users_get(ck.PrimaryID, ck.ServerID, CurrentUser.UserID, CurrentUser.UserSID);

                UserProfileDataContext udc2 = new UserProfileDataContext();             

                User = results.GetResult<Users_Get>().FirstOrDefault();
                merchantStates = results.GetResult<MerchantStates>().ToList();

Open in new window



The difference is that the calls that were made in the code above were removed.



Why are the other calls necessary for this code to correctly fill merchantStates?

It almost seems like each call is moving the "cursor" to the next set of data.

Is there a way to make it so it will find and use the CORRECT method (by name) instead of seemingly finding the correct method by how many calls have been made against the results var?
Avatar of jonnidip
jonnidip
Flag of Italy image

What does the "GetResult" method do?
And what is the data type returned by "Users_get"?
Avatar of Tom Knowlton

ASKER

What does the "GetResult" method do?
And what is the data type returned by "Users_get"?

Wait a minute...aren't you supposed to be answering questions, not asking them?  : P

(I am totally kidding)

Well, the data type returned is IMultipleResult.  So I get that multiple "result sets" can be returned by the result var.

I just don't understand why I have to call 8 or 9  "Get Results" methods in order to get to the one where the "merchantStates" List<  >  gets filled.

I only care about filling Users and merchantStates.  The other calls are wasted, except for the fact that they seem to advance the result set "cursor" so that it will return the correct results.

GetResult(  )  returns an IEnumerable.
ASKER CERTIFIED SOLUTION
Avatar of jonnidip
jonnidip
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Makes sense!

Thank you!

Tom
You're welcome!