The issue I have is that when using a string ("ProductId") for ordering it doesn't sort properly, e.g.
CultureInfo culture = new CultureInfo("nb-NO");
itemList = itemList.AsQueryable()
.OrderBy("ProductId", StringComparer.Create(culture, true))
.ToList();
Output:
Ååå
Ååå
Aaa
Aaa
Bbb
Bbb
but when using a key selector (s => s.ProductId) it does, e.g.
CultureInfo culture = new CultureInfo("nb-NO");
itemList = itemList.AsQueryable()
.OrderBy(s => s.ProductId, StringComparer.Create(culture, true))
.ToList();
Output:
Aaa
Aaa
Bbb
Bbb
Ååå
Ååå
I am using System.Linq.Dynamic.Core ver. 1.0.23.
I also tried with StringComparer.InvariantCulture, but its result is the same.
My itemList object(s) looks like this, and is a List<Inventory>
public class MyModels
{
public int Id { get; set; }
public DateTime CreateDate { get; set; }
public DateTime EditDate { get; set; }
}
public class Inventory : MyModels
{
public string ProductId { get; set; }
public string Name { get; set; }
public string Price { get; set; }
}
The issue I have is that when using a string (
"ProductId") for ordering it doesn't sort properly, e.g.but when using a key selector (
s => s.ProductId) it does, e.g.I am using
System.Linq.Dynamic.Corever. 1.0.23.I also tried with
StringComparer.InvariantCulture, but its result is the same.My
itemListobject(s) looks like this, and is aList<Inventory>