I need to bind Dapper.NET dynamic query with MS Charts.
So the question is , how do i get it done?
public class HomeController : Controller
{
private readonly ChartModel _model;
public HomeController(ChartModel model)
{
_model = model;
}
public ActionResult Index()
{
ViewModel.Message = "Welcome to ASP.NET MVC!";
return View();
}
public ChartResult GetChart()
{
var data = _model.GetChartData();
var chart = new Chart(400, 200, ChartTheme.Blue)
.AddTitle("Price enquiries")
.DataBindTable(???, "XXX");
return new ChartResult(chart, "png");
}
public ActionResult About()
{
return View();
}
}
this is the code i use.
Dapper can be used to conveniently populate an object model, such as a list - i.e.
var list = connection.Query<SomeType>(sql, args).ToList();
I guess the real question, then, is not "how to bind dapper to a chart", but rather, "how to bind a typed list to a chart"; for that - look at questions like this: MS Charts C# DataSource from array or List