0

I am storing data from my database into ObjectCache.

Looping through each row using a for statement whilst inserting a new object into the cache using .Set()

Data stores fine, except, its completely out of order than the original data set from the database. How am I able to preserve the original sort order of inserting into the cache?

I want to avoid remaking the Dictionary<string,object> in the ObjectCache so that it sorts how I want after it's been inserted since it's a lot more work than I was hoping for. Anyone know how to preserve the original sort order when adding to the cache? Unfortunately sorting the key won't help, it needs to be sorted by a field in the object.

RealWorldCoder
  • 1,031
  • 1
  • 10
  • 16
  • dictionary order is non-deterministic you would need to add your own rank value to sort the dictionary. see http://stackoverflow.com/questions/4007782/the-order-of-elements-in-dictionary – ozhug Jul 06 '15 at 06:05
  • I think you can use a List> to keeps all your items from db, then put the list into cache. When you do get from the list, order of items will not be changed. – hazjack Jul 06 '15 at 06:27

0 Answers0