我正在尝试根据数组索引对查询进行排序。请参阅下面的代码 -
query = data.Users;
query = query.Where(u=>u.IsActive);
query = query.OrderBy(u=>u.LName);
query = query.OrderBy(u=>u.Phone[0]);
除最后一行外,一切正常。它显示以下错误 -
NotSupportedException was unhandled.
The expression [10007].Phone.get_Item(0) is not supported.
编辑
我努力了 -
query = query.OrderBy(u=>u.Phone.First());
query = query.OrderBy(u=>u.Phone.FirstOrDefault());
电话是一个字符串数组。