- [HttpGet]
- public IEnumerable GetSCurvePlan(string WSId, string dtFrom, string dtTo, string ReportType)
- {
-
- List lstSCurveObj = new List();
- IEnumerable IenumObject = lstSCurveObj.GroupBy(val => val.ProgressDate.AddDays(((CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek) - val.ProgressDate.DayOfWeek) + 6))
- .Select(grouped => new
- {
- ProgressDate = grouped.Key,
- PlannedProgressPercentageWithWeightage = grouped.Sum(Pp => Pp.PlannedProgressPercentageWithWeightage),
- ActualProgressPercentage = grouped.Sum(Ap => Ap.ActualProgressPercentage),
- grouped.OrderByDescending(Pc => Pc.ProgressDate).First().PlannedPrgressPercentageWithWeightageCumulative,
- grouped.OrderByDescending(Ac => Ac.ProgressDate).First().ActualProgressPercentageCumulative
- }).OrderBy(o=> o.ProgressDate).ToList();
- return IenumObject;
- }
Q1) I have to return the data of the class in json format, so u can change anything if u want. my objective is that it should be optimised?
q2) is tolist() function is required, because, without it, it works? for optimisation.
as there is no where clause and it is used only once.
Q3) initially I was returning List but it was showing IEnumerable anonymous type cant be cast to List
so i converted it to ienumerbal how far it is good or there is other better ways?
Q4) as i have used orderby and tolist , then i have returened , will it keep the order or i have to write like following
return IenumObject.OrderBy(o => o.ProgressDate)
yours sincerely