Compound Primary Keys


Author
Message
Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Charles R Hankey (2/2/2012)
If I understand you correctly, I would use a view that had one char column concatenating the four columns ( with datetimes changed to string ) for my listview.  Ok, that get's me a tag.  But the BO where I'm doing data entry will also need that column as a pk, no?  I think that's what autonavigate looks for is a pk.


Yes you can have a custom field property (CFP) that will have the string value of your PK combination, and you can use that CFP from that point forward anywhere in SF controls.  In your SELECT to grab the data, include the virtual column with the same name as the CFP and it will be there from you in the BO to use:
EX: "SELECT (Your PK Combination) AS cfp_MyCustomPK, * FROM MyTable"

In your BO, create a CFP and name it cfp_MyCustomPK.  Here is a sample (in VB) of one of my CFP which expect the field value from the SELECT statement:

    <Browsable(False),
     BusinessFieldDisplayInEditor(),
     Description("Transaction Reference No."),
     DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
     Public Overridable ReadOnly Property [cfp_ReferenceNo]() As Integer
         ' Check to see if datatable contains the custom field in
         ' case object was filled by a method that doesn't contain the field.
         Get
             Dim columnName As String = "cfp_ReferenceNo"
             If Me.CurrentDataTable.Columns.Contains(columnName) Then
                 If Not TypeOf (Me.CurrentRow.Item(columnName)) Is DBNull Then
                     Return CInt(Me.CurrentRow.Item(columnName))
                 Else
                     Return 0
                 End If
             Else
                 Return 0
             End If
         End Get
     End Property


Keep in mind, that you can tell the BO which is the PK column to use, also in the ListView you can select any field to be used for its Tag property.  There are many ways you can go with this.  If you will not be adding new records to this BO I prefer my approach of the CFP since you can use that all over the framework once you have it in the BO.

Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Charles,

I posted a sample in VB of a class I created based on the StrataListView in which I added some of the functionality we need.  Check it here:

http://forum.strataframe.net/FindPost28459.aspx

Edhy Rijo

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Hey Eddy

Key is char(6) + char(2) + datetime + datetime

If I understand you correctly, I would use a view that had one char column concatenating the four columns ( with datetimes changed to string ) for my listview.  Ok, that get's me a tag.  But the BO where I'm doing data entry will also need that column as a pk, no?  I think that's what autonavigate looks for is a pk.

Of course, I could make it a customfield property of the BO and then use my own code to navigate to that record,  but I'm not sure that's easier than just building my own bo search in the SelectedIndexChanged out of the four values.
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
FWIW I did find the sample (thankfully in C# ) you created back in 2009 for Stratalistview.  I get how it works but there appears to be nothing like AutoNavigate so I am still pretty much on my own writing SelectedIndexChanged code. 

Unless you have some compound key magic on the old LV for me, it looks like I'm going through the lv.SelectedItems[0].Subitems[n].Text to create a search on the BO to get navigation. Sad
Edhy Rijo
E
StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)StrataFrame VIP (3.8K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Charles,

Nice seeing you back in the forum, even thought not for happy reasons Hehe

If I understand your issue correctly, you have a regular SF ListView which you want it to navigate to the correct BO record automatically but the PK value cannot be stored properly in the ListView.Tag, am I right?  What type is your PK?

Could you create a View with a calculate field of your PK, create a BO using the view then use that BO in the ListView?

Edhy Rijo

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Thanks Trent.  I've avoided Stratalistview as I could never find documentation after it first appeared three or so years ago.  And I don't believe at that time there were any builders.

Since I have about 25 listviews so far in this app using the original SF listview, I'd prefer for right now ( as in I have a code drop due at 6pm ) to sync movement in my current listview with the underlying BO.  Short of writing my own SelectedIndexChanged event code is there any way to leverage what the old SF Listview does to use a compound key like this?  I tried passing 4 tags, separated by commas - obviously that doesn't work .

Seems earlier posts in this thread hinted at some other approach?  I'm just not seeing it.

( I promise I will look at stratalistview but the pressure today would not make that an option )
Trent Taylor
Trent Taylor
StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)StrataFrame Developer (8.7K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Regardless of the list you are using, you can always use the tag of the row.  However, if you use the new StrataListView, there is a CustomData collection on each row that allows you store ANY type of data you want with a key.  I store all kinds of things in this as it is a collection and can store an data type of anything since it accepts an Object data type as the value.  The key is a string.  But by doing this, you can keep all of the logical data associated to a single row that you need.  It is a real life saver and something that I use all of the time...maybe that is why I put it in there Smile
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)Advanced StrataFrame User (798 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I have a PK that is
Symol ( char(6) ) + Cntry_code ( char(2)) + from_date ( datetime ) + thru_date ( datetime ))
( I did NOT design it but I wish I knew where the kids of the guy who did go to school ... )


that I would love to use in a tag for a Listview for autonavigate. 

Suggestions? 
StrataFrame Team
S
StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)StrataFrame Developer (3.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Oh, I gotcha... you need a property that is created that is bindable, not just the ability to get the property. Yes, I'll look into that Smile
Larry Caylor
Larry Caylor
Advanced StrataFrame User (902 reputation)Advanced StrataFrame User (902 reputation)Advanced StrataFrame User (902 reputation)Advanced StrataFrame User (902 reputation)Advanced StrataFrame User (902 reputation)Advanced StrataFrame User (902 reputation)Advanced StrataFrame User (902 reputation)Advanced StrataFrame User (902 reputation)Advanced StrataFrame User (902 reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

Ben,

Thanks for the info, I missed the updates to GetPrimaryKeyValue(). However I’m not clear on how I would use this to set a tag value for say a listview? If I create a custom CompundPrimaryKey Property for my BO, it appears in the drop down list of available tag fields. An Example would help.

-Larry

 

 

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search