I need a way to create an empty IOrderedEnumerable and IEnumerable>
//above IGrouping DynamicNode gets stripped out by stackoverflow :(
Reason: I create 3 empty list types (IOrdered, IGrouping, IEnumerable) then based on some other information (options a user specifies such as order by create date or group by month) I then call a function on it assigning a list of said type.
(short snippet)
//DOESNT WORK THIS IS THE PART I NEED
IEnumerable<DynamicNode> baseList = Enumerable.Empty<DynamicNode>();
IOrderedEnumerable<DynamicNode> orderedList = (IOrderedEnumerable<DynamicNode>)Enumerable.Empty<DynamicNode>();
IEnumerable<IGrouping<string, DynamicNode>> groupedList = (IEnumerable<IGrouping<string, DynamicNode>>)Enumerable.Empty<DynamicNode>();
//ABOVE DOESNT WORK THIS IS THE PART I NEED
if (order)
{
if (group)
{
groupedList = returnGroupedOrderedList(nodeList, ascending, useFeatured, groupBy, orderBy);
}
else
{
orderedList = returnOrderedList(nodeList, ascending, useFeatured, orderBy);
}
}
Anyone know how to do it?
ps If I haven't been clear enough please let me know how I can help you, help me :)
Thanks!
The first should work as is:
IEnumerable<DynamicNode> baseList = Enumerable.Empty<DynamicNode>();
The second should work with a little trick:
IOrderedEnumerable<DynamicNode> orderedList =
Enumerable.Empty<DynamicNode>().OrderBy(x => 1);
The third should work with a little change:
IEnumerable<IGrouping<string, DynamicNode>> groupedList =
Enumerable.Empty<IGrouping<string, DynamicNode>>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With