Displaying field from a joined table
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


12»»

Displaying field from a joined tableExpand / Collapse
Author
Message
Posted 04/20/2008 2:20:57 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Yesterday @ 11:54:57 PM
Posts: 121, Visits: 858
I imagine this concept will be the same whether the sql statement is executed from the front end or the cursor is returned from a stored proc

I left joined credit cards to customers ( handling nulls and returning "NO CARD ON FILE") so there is a cardnumber field being returned in the cursor that I get with the stored proc

At debug time in me.customersbo1.currentview I can see the cardnumber column with data.

I looked in BO mapper and there doesn't look to be anyplace there to fake the BO into created a property (probably just as well as I assume it could not be updateable)  Thought a custom field prop would be the way to go but

''' <summary>

''' Customer's Credit Card

''' </summary>

''' <remarks></remarks>

<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("Customer's Credit card"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public ReadOnly Property [cardnumber]() As System.String

Get

Return cardnumber

End Get

End Property

Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

'-- Create and return a new array of FieldPropertyDescriptor

' objects that contains the ReflectionPropertyDescriptor

' for the cust_fullname field.

Return New FieldPropertyDescriptor() { _

New ReflectionPropertyDescriptor( _

"cardnumber", GetType(CustomersBO))}

End Function

Return Cardnumber gets the error that it must be declared - but I'm not sure what the syntax is to tell it the field will be in the cursor at runtime

( I do realize that if I add a custom prop in this way I will probably need to always be sure it is provided in each data access scenario.  Does that mean I should be creating a view on the back end so the field is present in the definition when the bizobj is mapped?  No problem, if that's the case but wanted to make sure there wasn't another trick I was missing as I might want to display something like this without having to create an updateable view on the back end)

TIA

Charles

Post #15778
Posted 04/20/2008 3:04:25 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/16/2008 12:26:47 PM
Posts: 405, Visits: 1,682
Hi Charles,

Your custom field property should return a value and in your code the cardnumber has not value.  Modify the Return value to return the calculated field as follow:

Return Me.CustomersBO.cardnumber



Edhy Rijo
Progytech (Computer Consultants)
Post #15779
Posted 04/20/2008 3:06:31 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/16/2008 12:26:47 PM
Posts: 405, Visits: 1,682
Edhy Rijo (04/20/2008)

Return Me.CustomersBO.cardnumber

Sorry, it should be:

Return Me.cardnumber



Edhy Rijo
Progytech (Computer Consultants)
Post #15780
Posted 04/20/2008 4:08:15 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Yesterday @ 11:54:57 PM
Posts: 121, Visits: 858
Thanks, Edhy

I did get my two custom props (the cust_lastname in the tutorial and my new prop) into an array properly.  ( I rewrote my proc to pull the most recent order as creditcard is a varchar(max) and may be encrypted and I just wanted to simplify)

My new prop is Orderpo but my problem is in the GET SET

<Browsable(False), _
BusinessFieldDisplayInEditor(), _
Description("The customer's last order."), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public ReadOnly Property [orderpo]() As System.String
Get


Return orderpo

End Get
End Property

I get a warning that variable orderpo is used before it has been assigned a value and that may result in a null ref exception at runtime

If i use me.orderpo (which is available through intellisense) I get an error 'Expression recursivelyh calls the containing property'

Obviously I'm missing something. 

Post #15782
Posted 04/20/2008 7:47:24 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Yesterday @ 11:54:57 PM
Posts: 121, Visits: 858
I think I've got is

RETURN me.currentrow.item("orderpo")

seems to give me exactly what I want (I was trying something like that in the watch window earlier with me.currentview.item("orderpo") but of course now I see why that wouldn't work)

Found the right syntax by just searching around here on all the message re custom properties

This framework, this forum and this community ROCKS !!

Post #15783
Posted 04/20/2008 8:23:20 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 9:36:54 PM
Posts: 4,200, Visits: 4,251
Charles,

It looks like you got it going.  I didn't work this weekend so I wasn't out on the forum much.  But you did get it figured out.  Returning a field or column from a joined table is a must in the disconnected world.  So in order to interact with it, just create the custom property and then...as you discovered...call the Me.CurrentRow.Item("MyField") property on the return an you have it.  If you intend to bind this field to anything, you will need to override the GetCustomBindablePropertyDescriptors method and return a ReflectionPropertyDescriptor.  There are a ton of posts and docs regarding this, but if you get stuck just let me know.

This framework, this forum and this community ROCKS !!

I agree Thanks for your kind words...and thanks for your input, Edhy!  I know that Charles appreciated it!

Post #15784
Posted 04/20/2008 8:43:34 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/16/2008 12:26:47 PM
Posts: 405, Visits: 1,682
Returning a field or column from a joined table is a must in the disconnected world.  So in order to interact with it, just create the custom property and then...as you discovered...call the Me.CurrentRow.Item("MyField") property on the return an you have it. 

Trent, thanks for the explanation.

Charles, I am glad you find it.  In fact I was not sure on the right answer since I have not done that yet, but I knew it has something to do with the return value of the custom field property, now I know

Edhy Rijo
Progytech (Computer Consultants)
Post #15786
Posted 04/21/2008 7:02:42 AM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice