文檔首頁>>Stimulsoft Reports.WinForms教程-2019>>Stimulsoft Reports.WinForms教程:在報表中使用LINQ查詢
Stimulsoft Reports.WinForms教程:在報表中使用LINQ查詢
立即點擊下載Stimulsoft Reports.Ultimate最新版
本示例說明了如何在報表數(shù)據(jù)中使用Linq查詢。Linq語法允許您在使用數(shù)據(jù)源時使用最少的代碼執(zhí)行復雜的篩選、排序和分組操作。為此,您可以使用用于處理業(yè)務對象的方法:
public Form1() { InitializeComponent(); Item[] items = new Item[] { new Book{Id = 1, Price = 13.50, Genre = "Comedy", Author = "Jim Bob"}, new Book{Id = 2, Price = 8.50, Genre = "Drama", Author = "John Fox"}, new Movie{Id = 1, Price = 22.99, Genre = "Comedy", Director = "Phil Funk"}, new Movie{Id = 1, Price = 13.40, Genre = "Action", Director = "Eddie Jones"}}; var query1 = from i in items where i.Price > 9.99 orderby i.Price select i; report.Load("..\\Report.mrt"); report.RegBusinessObject("MyData", "MyData", query1); }
在下面的屏幕截圖中,您可以看到示例代碼的結(jié)果。