通过一下代码可以实现在Entity Framework 触发原始 SQL 查询
DBCL.DBEntities db = new DBCL.DBEntities();
var sql = "select sum(BQty) from BookTb1";
BookStockLbl.Text = db.Database.SqlQuery<int>(sql).Single() + "";
其中db为数据库对象
BookStockLbl为前端接收数据的Lbl
参考博客——
https://blog.csdn.net/a859745210b66a6/article/details/133441722
DBCL.DBEntities db = new DBCL.DBEntities(); var sql = "select sum(BQty) from BookTb1"; BookStockLbl.Text = db.Database.SqlQuery<int>(sql).Single() + ""; 标签:sql,db,Entity,Framework,DBCL,SQL,BookStockLbl,DBEntities From: https://www.cnblogs.com/yansans/p/17828509.html