How Do I Handle Foreign Keys Through List Controls?


Author
Message
John Kujur
John Kujur
StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)
Group: Forum Members
Posts: 5, Visits: 12
This has got to be really simple, as I have been doing this throughout my coding years, but I can't make it happen using SF.



I have an Organization BO, a Group BO, and a GroupOrganization BO. An Organization can belong to many groups and a Group can have many organizations. I want to use the GroupOrganization BO to handle this. (The GroupOrganization table just has two fields -- GroupId, and OrganizationId which are foreign keys referencing the primary keys in the respective tables).



On the GroupOrganization BO, I just want to have a list control displaying all available Organizations, and one more list control displaying all available Groups. I want to be able to choose a Group, then choose (multiple) Organizations and click 'Save', resulting in proper records which look like (GroupId, OrganizationId) where both of these are composite primary keys.



I need some guidance how to go about achieving this through SF.



Thanks, and let me know if I can be more descriptive.
Replies
John Kujur
John Kujur
StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)
Group: Forum Members
Posts: 5, Visits: 12
Thanks, I'm attaching the package file.
Attachments
ForeignKeySample.pkg (144 views, 12.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I will check this out....just curious, I noticed that your primary keys are TinyInt's...so I assume that you will never have more than 250 records in this table or recreate a record 250 times?
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
John,

Attached are two things....some updated StrataFrame DLLs and a Link Manager sample.  I ran into the problem you were encountering and I will explain it is just a minute.  First let me explain how to update your DLLs:

Updating SF DLLs:

  1. Extract the SF DLLs to a temp folder
  2. Drag the DLLs into the c:\windows\assembly folder (GAC)
  3. Copy those same files to C:\Program Files\Common Files\MicroFour\StrataFrame
  4. Restart all Visual Studio Instances

This will update your SF DLLs.

The Problem

Your entire problem surrounds the TinyInt as your primary key.  Your PKs were also autoincrementing which caused some additional side-effects.  A TinyInt is converted to a Byte in .NET (you can find this in the SQL Server Books Online).  The problem with this is that when a PK is auto-incrementing the framework will us negative numbers until the record is committed...obviously this won't work with a Byte since you cannot go below zero.  There was an additional problem that we found while testing your scenario that is the reason we gave you the new DLLs.  It has to do with a new record being added through a grid when there are already records populated within the Link Table in the BusinessLayerLinkManager while using TinyInt PKs.  This issue has been resolved with these DLLs. 

The Solution

You will notice that the business objects within the sample attached here have an alternate value returned on NULL.  Since the framework cannot create the negative PK place holders for a TinyInt and DbNull value is returned which will cause a number of errors.  To get around this, we set a Return Alternate Value on Null setting on each of the PKs to zero.  See the customized field property value through the BO Mapper below:


Note: This needs to be done on each of the TinyInt PKs.

Since your PKs aure auto-incrementing, they will properly return the new PK once saved, but this just prevents the DbNull error from happening (since the PK could not be set to a negative value).

Past that I think the sample is pretty self-explanitory.  Let me know if you have any other questions regarding this.

Attachments
StrataFrame.zip (161 views, 2.00 MB)
SampleLinkManager.zip (162 views, 782.00 KB)
John Kujur
John Kujur
StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)StrataFrame Beginner (15 reputation)
Group: Forum Members
Posts: 5, Visits: 12
Thanks Trent, Ben And Team.



Yes My PKs are TinyInts as the number of records will never cross two digits here; and I have them auto-incrementing as it is a simple solution. It is just a little application I'm doing to test out SF. So yes, since these are converted into Bytes it all makes sense now.



I haven't gone through the example yet, I'll be doing that now and will let you know.



I was just curious about whether other SF users should also have these new DLLs? Is this going into an update/release?



Thanks Again.
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I was just curious about whether other SF users should also have these new DLLs? Is this going into an update/release?

Only a few.  These DLLs contain the changes that will be released on Friday.  But it is stable as we are using this ourselves and anyone that is having specific problems we are letting have these DLLs.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
John Kujur - 19 Years Ago
StrataFrame Team - 19 Years Ago
John Kujur - 19 Years Ago
John Kujur - 19 Years Ago
Trent L. Taylor - 19 Years Ago
                         Thanks, I'm attaching the package file.
John Kujur - 19 Years Ago
                             I will check this out....just curious, I noticed that your primary...
Trent L. Taylor - 19 Years Ago
                                 John, Attached are two things....some updated StrataFrame DLLs and a...
Trent L. Taylor - 19 Years Ago
                                     Thanks Trent, Ben And Team.

Yes My PKs are TinyInts as the...
John Kujur - 19 Years Ago
                                         [quote]I was just curious about whether other SF users should also...
Trent L. Taylor - 19 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search