开发者

LINQ how to add an order by to this statement?

开发者 https://www.devze.com 2022-12-22 17:32 出处:网络
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\")

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消