best practice question - foreign key safe?

best practice question - foreign key safe?

Old forum URL: forums.lhotka.net/forums/t/9836.aspx


DaveMon posted on Monday, December 06, 2010

 

 

I have a question about best practices -  We have a CSLA based web app,  that stores information in a session while the user works, through multiple pages, before saving to db.

I have corrected a bug in the system,  but have a question on what CSLA experts recommend as a best practice.

**Background
my app works with surety bonds, each Bond has a Broker, and each Broker has a BrokerId (and many other fields also)

So we end up with code like this-

**example code*****

   if (SessionValue.CurrentADUser.IsAdmin)
            {
  SessionValue.CurrentRequest.Bond.BrokerId = 1;
     }

**example code*****

Other sections of the code refer to these brokerId a different way, by not using a foreign key i.e  "CurrentRequest.Bond.Broker.BrokerId"  instead of  "CurrentRequest.Bond.BrokerId"


I have been tasked with finding out if using foreign keys in this manner is: A. Safe and B.  recommended by CSLA as a best practice.?

Can someone please shed some light if this technique is a big no-no/ not recommended?  Thanks in advance!

Dave

Copyright (c) Marimer LLC