本文整理汇总了C#中SortedList.GroupBy方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.GroupBy方法的具体用法?C# SortedList.GroupBy怎么用?C# SortedList.GroupBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedList
的用法示例。
在下文中一共展示了SortedList.GroupBy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JsonResult
public JsonResult(Gale.REST.Queryable.Primitive.Result response, int offset, int limit)
{
List<object> _items = new List<object>();
foreach (var data in response.data)
{
int ordinal = 0;
var plainObject = new System.Dynamic.ExpandoObject();
var groupedFields = new SortedList<string, KeyValuePair<Gale.REST.Queryable.Primitive.Reflected.Field, Object>>();
foreach (var field in response.fields)
{
if (field.Name.IndexOf("_") > 0)
{
groupedFields.Add(field.Name, new KeyValuePair<Gale.REST.Queryable.Primitive.Reflected.Field, object>(field, data[ordinal]));
}
else
{
//Add Direct Property
((IDictionary<String, Object>)plainObject).Add(field.Name, data[ordinal]);
}
ordinal++;
}
//Order the Grouped Fields
var grouped = groupedFields.GroupBy((field) =>
{
return field.Key.Substring(0, field.Key.IndexOf("_")); ;
});
foreach (var group in grouped)
{
var diggedObject = new System.Dynamic.ExpandoObject();
foreach (var field in group)
{
var columnKey = field.Key.Substring(field.Key.IndexOf("_") + 1);
((IDictionary<String, Object>)diggedObject).Add(columnKey, field.Value.Value);
}
//Add Digged Object
((IDictionary<String, Object>)plainObject).Add(group.Key, diggedObject);
}
_items.Add(plainObject);
ordinal = 0;
}
//Set Values into the Base Response
base.offset = offset;
base.limit = limit;
base.total = response.total;
base.items = _items;
base.elapsedTime = response.elapsedTime.ToString("t");
}