查询大数据表的效率对比:Linq to SQL、Entity Framework、企业(9)
return db.ExecuteDataSet(dbCommand);
}
public IDataReader selectPro()
{
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetStoredProcCommand("SelectSchoolsAll");
return db.ExecuteReader(dbCommand);
}
public SqlDataReader selectNormalPro()
{
SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=ECPDB;Integrated Security=SSPI;");
SqlDataReader returnReader;
connection.Open();
SqlCommand command = BuildQueryCommand(connection, "SelectSchoolsAll", null);
command.CommandType = CommandType.StoredProcedure;
returnReader = command.ExecuteReader(CommandBehavior.CloseConnection);
return returnReader;
}
private static SqlCommand BuildQueryCommand(SqlConnection connection, string storedProcName, IDataParameter[] parameters)
{
SqlCommand command = new SqlCommand(storedProcName, connection);
command.CommandType = CommandType.StoredProcedure;
if (parameters != null)
{
foreach (SqlParameter parameter in parameters)
{
if (parameter != null)
{
// 检查未分配值的输出参数,将其分配以DBNull.Value.
相关新闻>>
- 发表评论
-
- 最新评论 更多>>