私はこれを読んでtopicと私のコードに当てはまります。Dynamic Linq&ICompareを使用するとエラーが発生する
//listSort contains ExpandoObjects
List<dynamic> listSort = new List<dynamic>(listDynamic.Count);
foreach (var item in listDynamic)
{
dynamic objDynamic = OrderBySpecialCharacter.ConvertToExpand(item);
string sortValue = OrderBySpecialCharacter.GetValueInExpandoObject(objDynamic, colSortText);// "Name");
objDynamic.Sort = OrderBySpecialCharacter.ConvertToACSII(sortValue.ToUpper());
listSort.Add(objDynamic);
}
List<dynamic> sortedList = new List<dynamic>();
if (colSort2 == null && colSort3 == null)
{
//Error in below line
sortedList = listSort.OrderBy(x=> x.GetReflectedPropertyValue("Sort"),new MrFourCompare<string>()).ToList();
}
----------------
public static ExpandoObject ConvertToExpand<T>(T objInput)
{
ExpandoObject objExpand = new ExpandoObject();
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(T));
IDictionary<String, Object> iExpand = ((IDictionary<String, Object>)objExpand);
foreach (PropertyDescriptor prop in properties)
iExpand.Add(prop.Name, prop.GetValue(objInput));
return (ExpandoObject)iExpand;
}
--------------------
そして私は、エラーを参照してください。
Severity Code Description Project File Line Suppression State Error CS0411 The type arguments for method 'Enumerable.OrderBy(IEnumerable, Func, IComparer)' cannot be inferred from the usage. Try specifying the type arguments explicitly. DemoDynamicObject C:\Users\MrFour-IT\Desktop\DemoDynamicObject\DemoDynamicObject\OrderBySpecialCharacter.cs 154 Active
私はそれを修正する方法がわかりません!私を助けてください!おかげ
これは私があなたの助けのために http://stackoverflow.com/questions/12350965/dynamic-linq-icompare –