Prevented OrderBy from throwing an error when presented with an empty list

This commit is contained in:
agrath
2011-09-01 08:45:43 -12:00
parent 51c76dfcd4
commit c097b0f250

View File

@@ -160,6 +160,10 @@ namespace System.Linq.Dynamic
Func<DynamicNode, object> func = (Func<DynamicNode, object>)lambda.Compile();
//get the values out
var query = typedSource.ToList().ConvertAll(item => new { node = item, key = EvaluateDynamicNodeFunc(item, func) });
if (query.Count == 0)
{
return source;
}
var types = from i in query
group i by i.key.GetType() into g
where g.Key != typeof(DynamicNull)