Add index and create
This commit is contained in:
@@ -238,33 +238,47 @@ namespace MileageTraker.Web.Utility
|
||||
}
|
||||
|
||||
public static Dictionary<string, List<string>> YearMonthList(IEnumerable<DateTime> dates)
|
||||
{
|
||||
var tuples =
|
||||
from d in dates
|
||||
orderby d descending
|
||||
select Tuple.Create(d.Year.ToString(), d.Month.ToString());
|
||||
|
||||
return GroupTuple(tuples);
|
||||
//return
|
||||
// (from d in dates
|
||||
// orderby d.Year descending
|
||||
// group d by d.Year
|
||||
// into yg
|
||||
// select
|
||||
// new
|
||||
// {
|
||||
// Year = yg.Key.ToString(),
|
||||
// MonthList =
|
||||
// (from o in yg
|
||||
// orderby o.Month descending
|
||||
// group o by o.Month
|
||||
// into mg
|
||||
// select mg.Key.ToString()).ToList()
|
||||
// }).ToDictionary(arg => arg.Year, arg => arg.MonthList);
|
||||
}
|
||||
|
||||
public static Dictionary<string, List<string>> GroupTuple(IEnumerable<Tuple<string,string>> tuples)
|
||||
{
|
||||
return
|
||||
(from d in dates
|
||||
orderby d.Year descending
|
||||
group d by d.Year
|
||||
(from t in tuples
|
||||
group t by t.Item1
|
||||
into yg
|
||||
select
|
||||
new
|
||||
{
|
||||
Year = yg.Key.ToString(),
|
||||
MonthList =
|
||||
Item1 = yg.Key,
|
||||
Item2List =
|
||||
(from o in yg
|
||||
orderby o.Month descending
|
||||
group o by o.Month
|
||||
group o by o.Item2
|
||||
into mg
|
||||
select mg.Key.ToString()).ToList()
|
||||
}).ToDictionary(arg => arg.Year, arg => arg.MonthList);
|
||||
}
|
||||
|
||||
public static RouteValueDictionary ToRouteValueDictionary(this NameValueCollection collection)
|
||||
{
|
||||
var routeValueDictionary = new RouteValueDictionary();
|
||||
foreach (var key in collection.AllKeys)
|
||||
{
|
||||
routeValueDictionary.Add(key, collection[key]);
|
||||
}
|
||||
return routeValueDictionary;
|
||||
select mg.Key).ToList()
|
||||
}).ToDictionary(arg => arg.Item1, arg => arg.Item2List);
|
||||
}
|
||||
|
||||
//public static IEnumerable<SelectListItem> ToSelectList<T>(
|
||||
|
||||
Reference in New Issue
Block a user