Linq to sql 主从表查询
private void BindProducts(int startRow)
{
NorthwindDataContext db = new NorthwindDataContext();
//var ca = from c in db.Categories
// where c.Products.Count > 2
// select new
// {
// id = c.CategoryID,
// name = c.CategoryName,
// 产品数量 = c.Products.Count,
// 产品 = c.Products.Sum(q => q.UnitPrice * q.UnitsOnOrder)
// };
var ca = from p in db.Products
where p.OrderDetails.Count > 2
select new
{
ID = p.ProductID,
Name = p.ProductName,
NumOrders = p.OrderDetails.Count,
Revenue = p.OrderDetails.Sum(o => o.UnitPrice * o.Quantity)
};
GridView1.DataSource = ca.Skip(startRow).Take(10);
GridView1.DataBind();
}
目前维护的开源产品:https://gitee.com/475660