Best Practice to Use Views or Tables with SQL Databases and BOs


Author
Message
Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
I still have to use (but not for much longer Smile) VPME and xCase2VPM and I will not miss either. I will certainly not miss the quirks or the extremely tedious view generation process that takes forever to run for a simple change Smile Or the massive list of views which contain many more fields than I actually want to query or the generation of "SELECT *" type statements which causes VFP to throw an error when the field order changes.....

To be honest, I was worried initially about SF as you code your own queries and I assumed this would be hard work. However, after using SF, it is a MUCH better approach and is extremely easy to do. Now the SF version of my VPME application is only quering the fields I need rather than some expanded list of fields created in a view generator.

I have been using SF every day now for months and I haven't found anything yet to grumble about Smile I am really angry with myself for not finding it years ago but I am determined to find something wrong with it so I can grumble Smile However, I suspect it will be a spelling mistake somewhere rather than a design flaw.

The best advice I can give anyone coming from a VPME background to SF is to totally forget about VPME and views. SF is in a different league and comparisions are pointless.

Just my 18 cents worth (sorry inflation).

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
Russell Scott Brown (11/03/2008)
Thanks.  I am not going to miss using Views, that is for sure.

Humm, don't think so. Smile I still use VPME with the PSP Libraries and xCase2VPM which takes care of creating all needed views for me, and even though I have been working with views for a long time, so far I don't miss anything from VFP while working with .NET/SF. 

I do miss some VPME features I was used to, like the form's builder and others but, I am pretty comfortable with the way things are going between me and SF/.NET.

Edhy Rijo

Russell Scott Brown
Russell Scott Brown
StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)
Group: Forum Members
Posts: 124, Visits: 597
Thanks.  I am not going to miss using Views, that is for sure.

I definitely plan to go with SF for the future.  VFP/VPME for only those apps already developed but over time even those will use SF.

Russ Brown (Using C#2010/SQL Server 2008)

Russell Scott Brown
Russell Scott Brown
StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)
Group: Forum Members
Posts: 124, Visits: 597
Thanks for all the very helpful comments.

I am glad I asked! 

Russ Brown (Using C#2010/SQL Server 2008)

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hola Juan.

Me alegro de haber ayudado. Cool

Juan Carlos Pazos
Juan Carlos Pazos
StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)StrataFrame User (228 reputation)
Group: Forum Members
Posts: 144, Visits: 227
Ivan

Thanks a lot for the sample. I find it very usefull.

I'm sorry for wrote in spanish, I just don't think and wrote as come to my mind. Glad to see that you can understand me.

Kindest regards

Smile Everything is possible, just keep trying...

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Juan.

I read the code I posted to you and noticed I didn't code some important features in it, so I corrected a bit:

    Private Sub MyBrowseDialog1_BrowseDialogClosed(ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogClosedEventArgs) Handles MyBrowseDialog1.BrowseDialogClosed
        '-- check if the BrowseDialog was canceled by user
        If e.Reason = MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogClosedReasons.UserCancelled Then
            Exit Sub
        End If

        '-- establish locals
        Dim lnCount As Integer
        Dim lnChosenPk As Integer

        '-- get the chosen row PK
        lnChosenPk = Me.MyViewInfoBO1.myview_pk

        '-- copy the data from the populated BO to another one without the duplicates
        '-- (I used to do something a lot more complicate at this point, thanks to Paul for the next line)
        Me.MyViewInfoBO2.CopyDataFrom(Me.MyViewInfoBO1.CurrentDataTable.DefaultView.ToTable _
          (True, New String() {"myview_pk"}), _
           MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)

        '-- get the number of unique rows
        lnCount = Me.MyViewInfoBO2.Count()

        '-- establish an array dimensioned with the number of rows in the BO
        Dim arPk(lnCount) As Integer

        '-- populate the array of PKs, so we can use it to populate the form BO with the found records
        For Each row As MyViewInfoBO In MyViewInfoBO2.GetEnumerable()
            arPk(MyViewInfoBO2.CurrentRowIndex) = MyViewInfoBO2.myview_pk
        Next

        '-- fill the Parent BO given the array of PKs
        Me.MyParentBO1.FillByPrimaryKey(arPk)
        '-- position the chosen row
        Me.MyParentBO1.NavigateToPrimaryKey(lnChosenPk)
    End Sub


Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hey Edhy.

I can read it, but not really write it. I asked for help over here... BigGrin

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Here you are.
  • Get your view ready with the Parent and all its children, remember to have the parent PK as a column in it.
  • Create a new BO in your application and use the Business Object Mapper to map it. Remember that if you are used to mapping selecting the DDT as a source, with a view you will need to go straight to the SQL Server, so deploy it first, and then map it.
  • Rebuild your project and drop 2 instances of the view BO on your form.
  • Drop a BrowseDialog and configure it to this BO type, use one of the instances of the BO as the BusinessObjectToPopulate.
  • Configure your BrowseDialog as usual. SearchFields, BrowseResultsLayout and so on.
  • Go to your BrowseDialog Events and create one for BrowseDialogClosed.

In it, put some code like the following:

    Private Sub MyBrowseDialog1_BrowseDialogClosed(ByVal e As MicroFour.StrataFrame.UI.Windows.Forms.BrowseDialogClosedEventArgs) Handles MyBrowseDialog1.BrowseDialogClosed
        '-- establish locals
        Dim lnCount As Integer

        '-- copy the data from the populated BO to another one without the duplicates
        '-- (I used to do something a lot more complicate at this point, thanks to Paul for the next line)
        Me.MyViewInfoBO2.CopyDataFrom(Me.MyViewInfoBO1.CurrentDataTable.DefaultView.ToTable _
          (True, New String() {"myview_pk"}), _
           MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)

        '-- get the number of unique rows
        lnCount = Me.MyViewInfoBO2.Count()

        '-- establish an array dimensioned with the number of rows in the BO
        Dim arPk(lnCount) As Integer

        '-- populate the array of PKs, so we can use it to populate the form BO with the found records
        For Each row As MyViewInfoBO In MyViewInfoBO2.GetEnumerable()
            arPk(MyViewInfoBO2.CurrentRowIndex) = MyViewInfoBO2.myview_pk
        Next

        '-- fill the Parent BO given the array of PKs
        Me.MyParentBO.FillByPrimaryKey(arPk)
    End Sub

That should be it. Wink

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
Ivan George Borges (10/31/2008)
Hola Juan.

Si, prepararé un ejemplo para usted y pondré aquí.

Aha, Ivan tu eres como una cajita de sorpresa, no sabia que hablabas y escribes en Español.Smile

Edhy Rijo

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