How do I use CopyDataFrom to remove duplicates from BO populated by Browse Dialog?


How do I use CopyDataFrom to remove duplicates from BO populated by...
Author
Message
Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Hi All.

I created a view that is a three table join so that I can use this view to populate my BO using the BrowseDialog. The problem is that this may result in multiple records in the BO that gets populated. I do not want the "real" BO being handled in my form to contain these mutliple records. So how can I use CopyDataFrom to ensure that I get only the DISTINCT records for my "real" BO?

TIA.

Marcia

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 Marcia.

Maybe you could drop another instance of your BO in your form and use it as your BrowseDialog's BusinessObjectToPopulate. Then in the BrowseDialogClosed method, if a OK was pressed by the user, you could filter your populated BO as needed and use the CopyDataFrom to copy the records to your primary BO.

As for how to filter the duplicated records, you could add a new Column to your BO for that purpose.

    Private Sub MyBO_CurrentDataTableInitialized() Handles MyBO.CurrentDataTableInitialized
        If Me.CurrentDataTable.Columns.Contains("myb_Duplicated") = False Then
            Me.CurrentDataTable.Columns.Add("myb_Duplicated", System.Type.GetType("System.Boolean"))
        End If
    End Sub

(You probably need to create the custom property for that column too)

Then you could go through all your records testing for duplicated ones, and flaging then as so. Filter on that flag before the CopyDataFrom.

Hope I could make some sense... Wink

Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Ivan George Borges (10/21/2008)
Hi Marcia.

As for how to filter the duplicated records, you could add a new Column to your BO for that purpose.

    Private Sub MyBO_CurrentDataTableInitialized() Handles MyBO.CurrentDataTableInitialized
        If Me.CurrentDataTable.Columns.Contains("myb_Duplicated") = False Then
            Me.CurrentDataTable.Columns.Add("myb_Duplicated", System.Type.GetType("System.Boolean"))
        End If
    End Sub

(You probably need to create the custom property for that column too)

Then you could go through all your records testing for duplicated ones, and flaging then as so. Filter on that flag before the CopyDataFrom.

Hope I could make some sense... Wink

Hi Ivan.

Thanks so much for the quick response. I wish I could say that this makes sense to me, but unfortunately, it doesn't Smile

I have used the CopyDataFrom method before when there was no chance of pulling back duplicate records. Basically, I am after a way to do a "SELECT DISTINCT" from the BrowseDialog BO into the "real" BO.

Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Hi Marcia,

You can do something like this to copy only distinct rows from one bo to another.

Me.RealBizObject.CopyDataFrom(Me.BrowseBizobject.CurrentDataTable.DefaultView.ToTable(True, New String() {"DistictColumn-ColumnName"}), MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)

Hope that helps

Paul

 


Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Paul Chase (10/21/2008)
Hi Marcia,

You can do something like this to copy only distinct rows from one bo to another.

Me.RealBizObject.CopyDataFrom(Me.BrowseBizobject.CurrentDataTable.DefaultView.ToTable(True, New String() {"DistictColumn-ColumnName"}), MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)

Hope that helps

Hi Paul.

Thanks - that does help. Now, if I use that syntax (converted to C#, of course Wink), will it use that column to determin which ones are the duplicates but copy all the other columns?

Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Thanks - that does help. Now, if I use that syntax (converted to C#, of course Wink), will it use that column to determin which ones are the duplicates but copy all the other columns?

Hiya Marcia

It works like Select Distinct ColumnName(s) fromTableName.

You will need to add the columns just as you would with a regular select distinct statement

So something like

Me.RealBizObject.CopyDataFrom(Me.BrowseBizobject.CurrentDataTable.DefaultView.ToTable(
True, New String() {"Cus_pk","cus_Name","Cus_anotherfld"}), MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)

=

Select Distinct cus_pk,cus_name,Cus_anotherfld from sometable.

 BigGrin

Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Paul Chase (10/21/2008)

It works like Select Distinct ColumnName(s) fromTableName.

Perfect - thanks for the explanation Smile Now I know why my code was blowing up with a "column active_flg does not belong to table client" BigGrin

Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Hi Paul.

I just wanted to thank you so much for your great advice. Once you explained how this worked, everything worked out great.

Thanks again for staying with a newbie like me Smile

Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Marcia

I'm glad I was able to help!! Wink

Paul

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
Yep, that was a lot eaiser! w00t
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