DatabaseOper/SQLHelper.cs
(开头部分) 195KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
// ===============================================================================
// 本例程示范了SqlHelper和SqlHelperParameterCache类的执行.
using System;
using System.Data;
using System.Xml;
using System.Data.SqlClient;
using System.Collections;
//51-aspx
namespace Microsoft.ApplicationBlocks.Data
{
/// <summary>
/// SqlHelper类意在综合SqlClient一般使用中的高性能和最好的应用能力.
/// </summary>
public sealed class SqlHelper
{
#region private utility methods & constructors
// Since this class provides only static methods, make the default constructor private to prevent
// instances from being created with "new SqlHelper()"
// 因为本类只提供静态方法,从而使得默认的私有构建器(constructor)防止由"new SqlHelper()"来创建实例.
private SqlHelper() {}
/// <summary>
/// This method is used to attach array of SqlParameters to a SqlCommand.
///
/// 本方法用于将SqlParameters参数集赋予SqlCommand.
/// This method will assign a value of DbNull to any parameter with a direction of
/// InputOutput and a value of null.
/// 本方法将一个DbNull值赋予任意的具有输入输出方向和null值的参数.
///
/// This behavior will prevent default values from being used, but
/// this will be the less common case than an intended pure output parameter (derived as InputOutput)
/// where the user provided no input value.
/// 这样就可以避免默认值被使用,但是更多的情况是用户有意只提供输出参数而不提供输入值.
///
/// </summary>
/// <param name="command">The command to which the parameters will be added</param>
/// <param name="command">将被赋予参数的命令</param>
///
/// <param name="commandParameters">An array of SqlParameters to be added to command</param>
/// <param name="commandParameters">将被赋予命令的SqlParameters参数集</param>
///
private static void AttachParameters(SqlCommand command, SqlParameter[] commandParameters)
{
if( command == null ) throw new ArgumentNullException( "command" );
if( commandParameters != null )
{
foreach (SqlParameter p in commandParameters)
{
if( p != null )
{
// Check for derived output value with no value assigned
// 检测没有被赋值的输出值
if ( ( p.Direction == ParameterDirection.InputOutput ||
p.Direction == ParameterDirection.Input ) &&
(p.Value == null))
{
p.Value = DBNull.Value;
后面还有 3286 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。