Dynamic Linq でカスタム IComparer を使用するための James McCormack のガイドを利用しようとしています。- http://zootfroot.blogspot.co.uk/2009/10/dynamic-linq-orderby.html?showComment=1347276236930#c11348033278810583を参照
クエリを使用して、文字列値の Enumerable を取得します。
.Select("fieldname").Distinct()
その後、使用してみてください
.OrderBy(item=>item.GetReflectedPropertyValue("fieldname"),new myComparer())
GetReflectedPropertyValue は、James によって次のように定義されたヘルパー メソッドです。
public static string GetReflectedPropertyValue(this object subject, string field)
{
object reflectedValue = subject.GetType().GetProperty(field).GetValue(subject, null);
return reflectedValue != null ? reflectedValue.ToString() : "";
}
しかし、「'System.Collections.Generic.IEnumerable' には 'OrderBy' の定義が含まれておらず、最適な拡張メソッド オーバーロード 'System.Linq.Dynamic.DynamicQueryable.OrderBy(System.Linq.IQueryable, string, params object [])' には無効な引数があります」
何か案は?私はこれに不慣れで、実際に経験して適切に学習する時間を得る前に、何かを機能させようとしています。