How do I filter a business object by a custom property?
 
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 )
      


««12345»»»

How do I filter a business object by a custom...Expand / Collapse
Author
Message
Posted 01/28/2008 8:48:19 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/03/2008 6:32:47 PM
Posts: 349, Visits: 1,205
Ah, Greg, much food for thought.  Thanks a ton for the explanation. 

The sp's in my code were placed in there for initial testing and I never removed them.  My goal was to replace them with calls to the corresponding business objects (which were not created at the time--they exist now). 

I am following you.  Really.  The thing that I am tripping up on is that once I give the DB the job of creating my custom properties (which are not custom properties to the business object anymore...they are actually columns in the remote data table) there remains little benefit to be derived from a custom property in the business object itself.

Well, getting late.  Time to go home.  Got an early and long day tomorrow.

Take care,
Bill

Post #13806
Posted 01/28/2008 9:11:01 PM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Yesterday @ 6:11:34 PM
Posts: 217, Visits: 1,060
Hi Bill

if I am forced to utilize a bank of stored procedures to create every data property of my business object.

No need to do this - the proc can return whatever you want. I my example the StationType was just part of the WHERE clause but the value being checked was in an associated table not the PUN table itself.

In our PUN table for example we have quite a number of custom fields:

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

        Dim boPUNType As System.Type = Me.GetType()

        Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "OperatorName", boPUNType), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "INIDescription", boPUNType), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "INIMaxHides", boPUNType), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "INIMaxWeight", boPUNType), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "INIMaxArea", boPUNType), _
            New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "PKBCode", boPUNType), _
            New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "ReceiveBatchCode", boPUNType), _
            New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "FlesherBatchCode", boPUNType), _
            New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "ShortTermBatchCode", boPUNType), _
            New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "TanningBatchCode", boPUNType)}
    End Function

#End Region

Our stored procedures return these values as needed. If we need to add more custom fields we can without breaking any existing code.

Regarding the other question - correct it wouldn't actually delete the rows until you did a BO.Save so you would want to carefull.

The best approach is not to return the data at all.

Cheers, Peter

Post #13808
Posted 01/28/2008 9:15:26 PM


StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Today @ 12:31:40 AM
Posts: 120, Visits: 644
Peter

Thanks so much for an very very useful example.  Coming from a VFP and Visual FoxExpress background I'm very used to thinking in terms of dynamic view parameters and only bringing as many records over the wire as absolutely necessary.  I'm very new to Strataframe and .NET in general and your code has helped a lot to translate some familiar concepts and give me a lot of ideas as to how I want to use the Strataframe framework.

Stuff like this always very much appreciated. 

Post #13809
Posted 01/29/2008 9:08:37 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 9:47:36 PM
Posts: 4,115, Visits: 4,185
You and Trent are suggesting that I need to relocate the business logic back into the database.

Actually, no.  There has been a lot of good dialog come from this post and this alone should be evident that there are many different ways to approach a problem.  First of all, if you create a custom property and want to sort on that property, there has to be an underlying column in the CurrentDataTable....you can, as you have seen from Greg and others, pull a faux field as part of your query....or in the CurrentDataRefilled event of your BO, you could progammatically add the columns into the CurrentDataTable so that you could filter on this as well:

CurrentDataTable.Columns.Add("MyAggregateField",GetType(Integer))

You could then, in your custom property, store off the value in the Set (or even the Get of the proper if it is readonly):

<Add standard attributes>
Public Readonly Property MyCustomProperty As Integer
   Get
      Me.Item("MyAggregateField") = 1 + 1
      Return CType(me.Item("MyAggregateField"), Integer)
   End Get
End Property

Taking this approach you could then sort and filter on the aggregate field.

Post #13818
Posted 01/29/2008 9:09:29 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/03/2008 6:32:47 PM
Posts: 349, Visits: 1,205
Peter Jones (01/28/2008)
...we have quite a number of custom fields...

Thanks, Peter!  I will review your code a bit more to see if I may be missing something. 

Can a user search on these custom fields (e.g. OperatorName="Bill") using the BrowseDialog?  Or, could I use code to sort on one of these fields (e.g. myBO.Sort = "INIMaxWeight DESC")?

Regards,
Bill

Post #13819
Posted 01/29/2008 9:16:43 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 9:47:36 PM
Posts: 4,115, Visits: 4,185
I could see an initial speed hit at the time of filling the BO, but not when the user is performing their own sorts, groupings and such on the corresponding DX datagrid.  Would this work?

Yes, but this will also make the BO dirty and if you do not want the table to be updated back at the server, you will have to AcceptChanges on the CurrentDataTable...otherwise this will be deleted from the server if a Save() is called:

MyBo.CurrentDataTable.AcceptChanges()
Post #13822
Posted 01/29/2008 9:17:55 AM
StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: 07/03/2008 6:32:47 PM
Posts: 349, Visits: 1,205
Trent L. Taylor (01/29/2008)
[quote]...you can, as you have seen from Greg and others, pull a faux field as part of your query...

Trent,

I have been known to be quite dense at times.  Sometimes saying something slightly differently fires certain synapses and things start clicking.  For me, it was the word "faux".  Thanks for pulling out the French.  English just wasn't getting through to me.

I will see what I can do with the creation of columns in an sp for the use with my custom properties.  Also, I need to spend some more time with Peter's code.  Looks like a good morning ahead.

Thanks, everyone, for your patience with me.
Bill

Post #13823
Posted 01/29/2008 9:19:35 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 9:47:36 PM
Posts: 4,115, Visits: 4,185
Can a user search on these custom fields (e.g. OperatorName="Bill") using the BrowseDialog? 

No.  The BrowseDialog creates Dynamic queries that are placed against the Database on the server, not the BO.  The BO is not where the query takes place....if you think about it, if the BO were where the query occurred, you would never pull any records back from the server.  So in this instance you will never be able to query on a custom property (unless it has an underlying field on the server that can be queried).

Post #13824