Print Page | Close Window

Comparing Entitylists

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=525
Printed Date: 11-Jun-2026 at 3:10pm


Topic: Comparing Entitylists
Posted By: Darren
Subject: Comparing Entitylists
Date Posted: 26-Oct-2007 at 7:44am

Some guidance needed please.

I have an EntityList called mUser that contains 3 columns.
I import data from an excel spreadsheet and populate a .net datatable
The datatable has the same 3 columns as the EntityList.
 
I would like to compare these objects and then return an updated entitylist back to the PersistenceManager.
 
Any ideas would be great or a alternative method.
 



Replies:
Posted By: davidklitzke
Date Posted: 26-Oct-2007 at 10:18am
Take the datatable created from the spreadsheet and add it to your solution using the ORM.  The added table may or may not have the same datasource as the table that is the source for your EntityList
 
You could now, of course, just compare each row in the table generated from the spreadsheet with each object in your EntityList, but here is something that is a little fancier. 
 
Create a new PersistenceManager and import your EntityList into the PM's cache.
 
For each row in the spreadsheet table:
 
(1)  If there could be duplicate rows between the two tables, search the new PM's cache for the row in the spreadsheet table with the 3 matching columns.  Be sure to use a QueryStrategy of CacheOnly.  If you find a match, it's a duplicate.  Ignore that row.
 
(2)  If the row is not a duplicate, create a new row (i.e., object), copy the values from the three columns, and add the new object to your EntityList.
 
 


Posted By: Darren
Date Posted: 29-Oct-2007 at 9:46am

David

The excel sheet is loaded at runtime , so i would not be able to use the ORM mapper.
 
I have that 3column datatable to compare against the entitylist
 
Do you have code sample for doing the compare this way.
 
I can do this with 2 .net datatables no problem using the merge method.


Posted By: davidklitzke
Date Posted: 29-Oct-2007 at 10:06am
You wouldn't necessarily have to use the ORM Mapper on the data coming from the spreadsheet.  Just read each row of the spreadsheet.  Extract the three columns from the row, and then query the EntityList for a match.


Posted By: Darren
Date Posted: 30-Oct-2007 at 8:37am
Got it to work david..... Thanks
 
I dont know what i was thinking.....guess i just got a carried away with trying to over complicate things.....who knows.
 
We all have our bad days.....lol
 



Print Page | Close Window