本文整理汇总了C#中Microsoft.VisualStudio.TestTools.UnitTesting.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.VisualStudio.TestTools.UnitTesting.OrderBy方法的具体用法?C# Microsoft.VisualStudio.TestTools.UnitTesting.OrderBy怎么用?C# Microsoft.VisualStudio.TestTools.UnitTesting.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualStudio.TestTools.UnitTesting
的用法示例。
在下文中一共展示了Microsoft.VisualStudio.TestTools.UnitTesting.OrderBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Sort
public void Sort()
{
var readCommand = new ReadCommandInfo
{
OrderByProperties = new[]
{
new OrderByProperty { Property = "Name", Descending = true },
new OrderByProperty { Property = "Size", Descending = false },
}
};
IQueryable<Entity2> query = new[]
{
new Entity2 { Name = "b", Size = 2, Ignore = 1 },
new Entity2 { Name = "b", Size = 2, Ignore = 2 },
new Entity2 { Name = "b", Size = 3, Ignore = 3 },
new Entity2 { Name = "b", Size = 1, Ignore = 4 },
new Entity2 { Name = "a", Size = 1, Ignore = 5 },
new Entity2 { Name = "c", Size = 3, Ignore = 6 }
}.AsQueryable();
query = query.OrderBy(item => item.Ignore); // SortAndPaginate should ignore previous ordering, not append to it.
var result = GenericFilterHelper.SortAndPaginate(query, readCommand);
Console.WriteLine(result.ToString());
Assert.AreEqual(
"c3, b1, b2, b2, b3, a1",
TestUtility.Dump(result, item => item.Name + item.Size));
}