.net - Linq statement to iterate through a collection and making sure each item is in the correct order? -


मुझे एक सरल IEnumerable & lt; foo & gt; Foos; यह संग्रह डीबी कॉल के कुछ परिणाम हैं।

मुझे यह सुनिश्चित करना है कि सूची में प्रत्येक वस्तु का सही ढंग से आदेश दिया गया है डीबी या तो रिटर्न देता है

  • id द्वारा क्रमबद्ध, सबसे कम से उच्चतम जैसे। 1, 2, 3, 4 ,. ... आदि
  • बनाये गये दिनांक से आदेश दिया, कमी (सबसे हाल ही में, पहले)।

क्या यह त्वरित linq कथन के साथ किया जा सकता है .. यह?

उदा। आशंका.आईएसटीआरयू (.. यहां लिंक्स का कथन सम्मिलित है ..)

वर्तमान में, मुझे पाशन के लिए मिला है और पिछली प्रविष्टि को याद रखना और जांचना है कि यदि उस का मान है, तो वहाँ एक मूल्य था। यह महसूस होता है ... बोझिल।

कोई भी विचार?

आप अपने तुलना कर सकते हैं संग्रहित संस्करण के लिए संग्रह:

  संग्रहअसर्ट। ऐरेक्वॉल (foos.ToList (), foos.OrderBy (f = & gt; f.Id));  

या:

  कलेक्शन एसेट। ऐरेक्वॉल (foos.ToList (), foos.OrderByDescending (f = & gt; f.DateCreated));  

Comments

Popular posts from this blog

c++ - QtQuick: QQmlApplicationEngine failed to load component qrc:/main.qml:23 Invalid attached object assignment -

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

iphone - Smoothing a rounded stroke in Core Graphics -