Calling a Generic BO


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
You are welcome Terry.

I am glad you found the problem.  And keep in mind that SF BOs are greatly flexible, extensible and powerful, little by little I found the logic used behind them very nice and worthy specially when working with several projects at the same time.

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I found the error that was causing the wrong data to load. Thank you again for your help.
Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I had my code just like yours but I was not getting the correct data. Therefore, I wanted to make sure I could do it the way you indicated and that I originally had,  but I must have something not quite right in my other code which is giving me the wrong data.  I did put a break on the code but I think I was looking for the BO that was being used and did not find it and did not pay any attention to the table being used.
Thank you again for your excellent help.
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Terry,

Your code is using the objbo.FillDataTable(cmd) instead of Me.FillDataTable(cmd).

Here is how it should be.  If you put a break in Me.FillDataTable(cmd) then see the value of cmd.Commandtext, notice that the correct table for the instance of the BO is used, remember "Generic", each BO is created for a specific table, hence the String.Format() code, so when you drop a BO and run the FillAllData() it will work just fine.  It is a good idea to take a look at the SF source code to learn how they use this generic logic for the FillBy... methods in the BO class.

    Public Overridable Sub FillAllData()
        Using cmd As New SqlCommand()
            cmd.CommandType = CommandType.Text
            cmd.CommandText = String.Format("Select * From {0}"Me.TableNameAndSchema)

            Me.FillDataTable(cmd)
        End Using
    End Sub


Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
OK but I think I am having trouble with it filling the correct BO since I am using the same Sub to fill multiple BO's but I will try again and see what happens. Thanks.
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Terry,

You don't need to pass any parameter nor the current BO.

Your current class, by inheriting the base BO it will know from which BO the method is executing, so when you reference Me in the base BO code it will be using whatever BO you have inherited from the base.

It may sound too easy, but it works and it is the way it is Smile

Edhy Rijo

Terry Bottorff
Terry Bottorff
Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)Advanced StrataFrame User (770 reputation)
Group: Forum Members
Posts: 448, Visits: 12K
I have a generic BO with the following Sub:

Public Sub FillAllData(ByVal objbo As Object)
        Using cmd As New SqlCommand
            cmd.CommandType = CommandType.Text
            cmd.CommandText = String.Format("Select * from {0}", Me.TableNameAndSchema)
            objbo.FillDataTable(cmd)
        End Using
    End Sub

Then I add a BO to my project called CowboysBO which I make sure Inherits from my generic BO. Then I call the sub using the following:

Me.CowboysBO1.FillAllData(Me.CowboysBO1)

Is my logic OK or should I be doing something else? I will use the sub to fill several different BO's and that is why I thought I needed the objbo. The above code seems to work but I don't want to get Bitten.
TIA.......


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