Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I use for .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 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 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...

What I have tried:

I try to get crystal report from normally but i want to this condition how to solve?
Posted
Updated 2-Aug-17 4:38am
v2

 
Share this answer
 
You must have to create dataSet for crystal report and configure them with your data entities, while return data from your DAL(Data Access layer). When you will create crystal report, it will ask for dataSet, then select the appropriate dataSet you have created for that report, asfter creation, that dataSet will be listed in your field explore for use.
 
Share this answer
 
Comments
[no name] 2-Aug-17 7:58am    
Hope it will helpful for you, please don't forget to mark my good rating. Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900