Hi,
it is me again
I am continuing my exporation of LLBLGen and I have a question about fetching data from tables related to one. Specifically, I have this CTAC_USERS table that lists a bunch of users in my system. Each of these users belongs to a CTAC_DEPARTMENT. Is the code contained in the block "IS THIS THE BEST WAY?" the best I can use? It looks really complicated given what I want to get. Isn't there a simpler way?
var validUser = (from x in metadata.CTAC_USERS
where
(x.USERID.Trim().ToUpper() == aUserId.Trim().ToUpper())
&&
(x.PASSWORD == PasswordManager.EncodePassword(aPassword))
select x).First();
aLoginInformation = new LoginInformation();
aLoginInformation.UserId = validUser.USERID.ToUpper();
// IS THIS THE BEST WAY?
validUser.CTAC_DEPARTMENTS = (CTAC_DEPARTMENTSEntity)cobraAdapter.FetchNewEntity(
new CTAC_DEPARTMENTSEntityFactory(),
validUser.GetRelationInfoCTAC_DEPARTMENTS());
// END OF QUESTION
aLoginInformation.Department = validUser.CTAC_DEPARTMENTS.NAME;
aLoginInformation.UserName = validUser.FIRSTNAME + " " + validUser.LASTNAME;
aSystemConfiguration = new SystemConfiguration();
In addition to that, I tried to see if validUser.GetRelatedData would do the loading for me, but it only returns a dictionary whose keys are null.
Any advice?
Thanks