How to check for duplicates on current business object


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I am using a BO with multiple rows taken from the Database Table and want to ensure that I do not have any duplicates (On the BO) before I save.

If I was doing this against the database Table, I would issue someting like:

Select Country , Count(Country) as MyCount from MyTable Group by Country                 and then Test that myCount was not greater than 1

Is there any similar construct I can use for Business Object   i.e. be able to search through the BO and let it throw up any duplicates.
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
Michel Levy
Michel Levy
StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)
Group: StrataFrame Users
Posts: 193, Visits: 9K
Hi Gerard,

I use QueryAdataset for that purpose (locally querying data in a BO in T-SQL). You'll find it here http://www.queryadataset.com/
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan. Thanks for replying.

I have had a look at the thread and the CopydataFrom method but cannot see any option to copy 'Just' duplicated records, or insert a 'Group By' statement.  An example of a CopyDataFrom to copy duplicated records only would be very helpful
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
Did you read Paul's post? Or maybe I am misunderstanding what you are looking for.

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


This should copy only "distinct" rows from MyOtherBO to MyBO, based on the "DistinctColumn-ColumnName".
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan. I am not seeing this. Maybe an example might clarify.

Say in the BO . I have following:

IRELAND
UK
USA
JAPAN
CHINA
IRELAND
FRANCE
BELGIUM
CHINA


I want the duplicates in this (So that I can display an error message , as there should not be any duplicates) . So I want returned:-

IRELAND
CHINA    


(If I was doing this in Sql, I would use a Select Country ,Count(Country) as MyCount from Mytable Group by Country   (And anywhere MyCount > 1 are the duplicates)
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Michel. Thanks for your reply.

This looks like what I want,  but I see its another chargeable piece of software (Not that much I admit but all the bits are starting to add up (e.g. Vis Studio, SF,DEVEX Grid, Devex Reports, Excel Creator etc  and 3 or 4 other bits and pieces... its starting to get a bit difficult to keep track of them all !!......). I will try to exhaust other possibilities first , and if I make no headway, may have to come back to this.
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
OK Gerard. Sorry, I thought you wanted a BO free of the duplicates. In fact you want the ones that are duplicates.

There might be easier ways to do it, but I would iterate through your BO and check each row if there is any other with the same content. Everytime I found one, I would store it in some kind of array, collection or even another instance of the same BO.

To look for duplicates, you can use the BO.CurrentDataTable.Select function, as in:

MyBO.CurrentDataTable.Select("MyColumnName = " & MyColumnCurrentValue & " AND MyPrimaryKeyColumnName <> " & MyCurrentPrimaryKeyValue).Length

If this line returned anything greater than 0 this would tell you this row had a duplicate and you could add it to your DuplicatesBO to show the user once finished.
Edited 13 Years Ago by Ivan George Borges
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan.

I have just started to play around with Linq statements (from a Datatable) and it appears to be quite easy to 'Group By' using the Inernal Table from the BO. In that Linq stuff only came  in in .Net 3.5 , would you anticipate any problems using this with SF (I had any projects running on Net 2) . I have changed the Project to 3.5 and have not noticed any problems yet. I would imagine that a Linq group By Statement might be faster than itrating through each BO and doing a search for a duplicate on each row. The particular maintanance forms that I want to validate could have thousands of rows so speed will be a factor
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
Sorry, but I am affraid I have no expertise on the subject to give you a more accurate answer.

Maybe someone else will chime in and help you with that. You could also run a test on different approaches and decide which goes better for your conditions.
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