I am reading a file and creating 100s of objects at a time. I am looping through a ReadOnlyList of existing items to check for duplicates. If there are no duplicates I add another item. I dont want to have to pull down a new ReadOnlyList from the database to continue checking for duplicates. Is there a way to add a new item to the ReadOnlyList temporarily. I don't want to do any writes to the database, I just want to include the new ObjectInfo item in the collection. Is this possible?
rbellow:I am reading a file and creating 100s of objects at a time. I am looping through a ReadOnlyList of existing items to check for duplicates.
Not a direct answer to your question, but this might be useful to consider.
The algorithm you described runs slower and slower the more objects there are in the file.
This is because each object has to loop thru all the objects that came before it.
You should consider another algorithm, like attaching a sorted collection to it. That way (presumably) the sorted list can check for the existence much faster.
The CSLA Contrib class ObjectListView might work nicely, as might the CSLA class SortedBindingList. Haven't had to use either for this purpose as I get most of my data from a SQL database and I can solve the problem using SQL.
Copyright (c) Marimer LLC