开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜