I use .net mvc 5 c# repository pattern with database first approach, In my Service layer i calculate and apply group by condition on there and pass this data into viewmodel and razor view, my question is can i used this viewmodel (with data) for creating the crystal report from this viewmodel ? crystal report is installed on visual studio (2015). code information are
code on controller are
public ActionResult Top20SupplierReport()
{
var AllSupplier = _supplier.Top20Supplier();
}
Service layer code are
public List<GroupBySupplierVM> Top20Supplier()
{
var AllSupplier = //code for get all supplier list from database
var groupByData = from sup in AllSupplier
group sup by sup .cf02supplier_Name into g
let TotalVol = g.Sum(x => x.cf08collection_Received_Volume)
let TotalAmount = g.Sum(x => x.cf08collection_Balance)
orderby TotalVol descending
select new GroupBySupplierVM
{
Key = g.Key,
Values = g.ToList(),
TotalReceivedVolume = Convert.ToDouble(TotalVol),
TotalBalance = TotalAmount
};
return groupByData.Take(20).ToList();
}
ViewModel are
public class GroupBySupplierVM
{
public string Key;
public List<SupplierVM> Values;
[Display(Name = "Total")]
public double TotalReceivedVolume { get; set; }
public double? TotalBalance { get; set; }
}
and
public class SupplierVM
{
public int cf02supplier_Id { get; set; }
public string cf02supplier_Address { get; set; }
public string cf02supplier_Name { get; set; }
public string cf02supplier_City_Id { get; set; }
public string cf02supplier_Telephone { get; set; }
public string cf02supplier_MobileNo { get; set; }
public decimal cf02supplier_Balance { get; set; }
......
// other Entity are also there
}
can i create crystal report from the GroupBySupplierVM ? if yes how to use on crystal report and how to show on view page ? anybody have knowledge about this how to use on crystal report. Please help me...