Pseudo Class when you need a generic object

        public class PseudoProduct : calldetail_viw
       {
       };

public List<calldetail_viw> GetTeamMonthlySummary()
       {
       
           int currentmonth = DateTime.Today.Month;
           int lastmonth = DateTime.Today.AddMonths(-3).Month;


           var calldata = (from c in db.calldetail_viw
               where c.ConnectedDate.Value.Month >= lastmonth
                     && c.ConnectedDate.Value.Month <= currentmonth
                     && c.LocalName == "myaccountrep"
                     && c.CallDirection=="Inbound"
               group c by new {c.AssignedWorkGroup, month = c.ConnectedDate.Value.Month}
               into g
               select new PseudoProduct
               {
                   AssignedWorkGroup = g.Key.AssignedWorkGroup,
                   CustomNum1 = g.Key.month,
                   CustomNum2 = g.Count()
               });
     
           var cl = new List<calldetail_viw>();
           foreach (var item in calldata)
           {
               cl.Add(new calldetail_viw {
                           AssignedWorkGroup = item.AssignedWorkGroup,
                           CustomNum1 = item.CustomNum1,
                           CustomNum2 = item.CustomNum2,
                   });
            }
           return cl;
       }

Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax