Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的 EF 播种机中运行一个简单的自定义 SQL 查询,如何实现一个简单的 SQL 查询并将结果(一个 count(),只是一个整数)存储在 ac# 变量中?
试试这样:
var cmd = db.Database.Connection.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "/*query*/"; cmd.Parameters.Add(new SqlParameter("@param", paramValue)); var value = cmd.ExecuteScalar();