Reputation: 15
I have a Class
public class SizesClass
{
public int Sizeid { get; set; }
public string SizeNumbers { get; set; }
}
That datas in SizeNumbers is like 20*20*30
then i have a list of this class that i want order this by one of those numbers.
var orderByDescending = Sizes.OrderBy(x => x.SizeNumbers.Split('*')[2]);
but var orderByDescending
turn into null and exeption said
The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities.
Upvotes: 0
Views: 668
Reputation: 3835
Maybe this?
var orderByDescending = Sizes.AsEnumerable.OrderBy(x => x.SizeNumbers.Split('*')[2]);
Because LINQ to Entities does not support 'ArrayIndex' we need to load all the data into memory, we can achieve that using AsEnumerable() (or using ToList()) then we can do all the order by on the in memory collection.
Upvotes: 1