1.右键项目,添加 新建项-》数据-》数据集
2.使用sql语句建立数据集,尽量包含所有的字段
3.右键项目 ,添加报表,设计报表,然后添加数据集
4.在controll中,
LogisticsDbContext db = new LogisticsDbContext();
var e = from p in db.instocks
。。。。。。
select new
{
。。。。。。
};
byte[] renderedBytes;
string mimeType;
string path = Server.MapPath("~/Report/Report1.rdlc");
renderedBytes = PublicHelper.PrintReport(path, e, out mimeType); //很多地方可以搜到类似的代码
return File(renderedBytes, mimeType);
就可以了