Orderby 使用 C# LINQ
Orderby using C# LINQ
我想在 LINQ
中转换以下 SQL 查询
Select * from EmpCode order by Left(EmpCode,4) Right(EmpCode4)
是否可以像这样进行 LINQ 查询?
如果我能正确读出你的错别字
var result = listOfEmpCode.Orderby(x => x.SubString(4))
.ThenBy(x => x.SubString(x.Length-4))
.ToList();
注意:这不会检查有效的字符串长度.. 添加胡椒粉和盐调味
Enumerable.OrderBy Method (IEnumerable, Func)
Sorts the elements of a sequence in ascending order according to a
key.
Enumerable.ThenBy Method (IOrderedEnumerable, Func)
Performs a subsequent ordering of the elements in a sequence in
ascending order according to a key.
String.Substring Method (Int32, Int32)
Retrieves a substring from this instance. The substring starts at a
specified character position and has a specified length.
Getting Started with LINQ in C#
而这一篇要彻底
我想在 LINQ
中转换以下 SQL 查询Select * from EmpCode order by Left(EmpCode,4) Right(EmpCode4)
是否可以像这样进行 LINQ 查询?
如果我能正确读出你的错别字
var result = listOfEmpCode.Orderby(x => x.SubString(4))
.ThenBy(x => x.SubString(x.Length-4))
.ToList();
注意:这不会检查有效的字符串长度.. 添加胡椒粉和盐调味
Enumerable.OrderBy Method (IEnumerable, Func)
Sorts the elements of a sequence in ascending order according to a key.
Enumerable.ThenBy Method (IOrderedEnumerable, Func)
Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
String.Substring Method (Int32, Int32)
Retrieves a substring from this instance. The substring starts at a specified character position and has a specified length.
Getting Started with LINQ in C#
而这一篇要彻底