LINQ how to add an order by to this statement?
I have the following LINQ that I would like to also order by file creation date, how is this done?
taskFiles = taskDirectory.GetFiles(Id + "*.xml")
.Where(fi => !fi.Name.EndsWith("_update.xml"开发者_运维百科, StringComparison.CurrentCultureIgnoreCase))
.ToArray();
taskFiles = taskDirectory.GetFiles(Id + "*.xml")
.Where(fi => !fi.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase))
.OrderBy(fi => fi.CreationTime)
.ToArray();
or
var taskFiles = from taskFile in taskDirectory.GetFiles(Id + "*.xml")
where !taskFile.Name.EndsWith("_update.xml", StringComparison.CurrentCultureIgnoreCase)
orderby taskFile.CreationTime
select taskFile;
精彩评论