Hello,
I have an EntityCollection<OrderDetailsEntity> bound to a DataGridView for in-memory editing.
An OrderDetailEntity is made of the following fields :
-IDProduct (long)
-NoColor (short?)
-IDSize (long?)
-Quantity (decimal)
The end-user can populate the collection automatically by using a variety of tools (for example : importing an another order, reordering a range of sold products...)
The problem is that the entities in the collection must be unique according to their <IDProduct><NoColor><IDSize> values, so every time the user tries to add a new entity, I have to check if such an OrderDetailEntity already exists, if it does, I increase the Quantity, if not, I insert a new OrderDetailEntity in the collection.
I currently use findMatches to do that because it is the easiest way, but it's way too slow when you have to bulk insert 4200 command lines in an existing order (takes 240 seconds on a good computer) 96% of that time is taken by FindMatches (according to DotTrace).
I have to find a way to speed up the checking, I'm thinking about indexing the position of the entities in the collection according to their <IDProduct><NoColor><IDSize> combo in a dictionary, but I'm not sure if it's a good idea or not...
Any suggestions?