• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IDbCommand类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IDbCommand的典型用法代码示例。如果您正苦于以下问题:C# IDbCommand类的具体用法?C# IDbCommand怎么用?C# IDbCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDbCommand类属于命名空间,在下文中一共展示了IDbCommand类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateRowUpdatedEvent

		protected override RowUpdatedEventArgs CreateRowUpdatedEvent(DataRow dataRow, IDbCommand command,
		                                                             StatementType statementType,
		                                                             DataTableMapping tableMapping)
		{
			NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "CreateRowUpdatedEvent");
			return new NpgsqlRowUpdatedEventArgs(dataRow, command, statementType, tableMapping);
		}
开发者ID:seeseekey,项目名称:CSCL,代码行数:7,代码来源:NpgsqlDataAdapter.cs


示例2: BuildCommand

        public static void BuildCommand(IDbCommand cmd, string sql, params object[] parameters)
        {
            if (cmd == null) throw new ArgumentNullException("cmd");
            if (String.IsNullOrEmpty(sql)) throw new ArgumentNullException("sql");

            if (parameters == null)
            {
                parameters = new object[0];
            }

            cmd.CommandText = new Regex(" *[\r\n]+ *").Replace(sql, " ");

            var parameterNames = FindUniqueParameters(sql);
            if (parameterNames.Count != parameters.Length)
            {
                throw new MicrOrmException(String.Format("Parameter count mismatch.  {0} in the SQL string, {1} supplied", parameterNames.Count, parameters.Length));
            }

            for (var i = 0; i < parameters.Length; i++)
            {
                if (!parameterNames.ContainsKey(i))
                {
                    throw new MicrOrmException(String.Format("Parameter ordinal mismatch.  Parameter with ordinal {0} is missing in the SQL string", i));
                }
                var dbParameter = cmd.CreateParameter();
                dbParameter.ParameterName = parameterNames[i];
                dbParameter.Value = parameters[i];
                cmd.Parameters.Add(dbParameter);
            }
        }
开发者ID:ChrisMH,项目名称:HoganUtilities,代码行数:30,代码来源:QueryBuilder.cs


示例3: AddParameter

 public static void AddParameter(IDbCommand dbCommand, string nombre, object value)
 {
     IDbDataParameter dbDataParameter=dbCommand.CreateParameter ();
     dbDataParameter.ParameterName = nombre;
     dbDataParameter.Value = value;
     dbCommand.Parameters.Add (dbDataParameter);
 }
开发者ID:DiegoDeBelda,项目名称:AD,代码行数:7,代码来源:DbCommandHelper.cs


示例4: GetDataAdapter

        public override System.Data.IDataAdapter GetDataAdapter(IDbCommand cmd)
        {
            SqlCommand sqlCmd = (SqlCommand)cmd;
            SqlDataAdapter sqlAdpt = new SqlDataAdapter(sqlCmd);

            return sqlAdpt;
        }
开发者ID:BlueSwimmingFrog,项目名称:SqlGenerator,代码行数:7,代码来源:SqlServerGenerator.cs


示例5: Enlist

		/// <summary>
		/// Enlist the <see cref="IDbCommand"/> in the current <see cref="ITransaction"/>.
		/// </summary>
		/// <param name="command">The <see cref="IDbCommand"/> to enlist in this Transaction.</param>
		/// <remarks>
		/// <para>
		/// This takes care of making sure the <see cref="IDbCommand"/>'s Transaction property 
		/// contains the correct <see cref="IDbTransaction"/> or <see langword="null" /> if there is no
		/// Transaction for the ISession - ie <c>BeginTransaction()</c> not called.
		/// </para>
		/// <para>
		/// This method may be called even when the transaction is disposed.
		/// </para>
		/// </remarks>
		public void Enlist(IDbCommand command)
		{
			if (trans == null)
			{
				if (log.IsWarnEnabled)
				{
					if (command.Transaction != null)
					{
						log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction");
					}
				}

				command.Transaction = null;
				return;
			}
			else
			{
				if (log.IsWarnEnabled)
				{
					// got into here because the command was being initialized and had a null Transaction - probably
					// don't need to be confused by that - just a normal part of initialization...
					if (command.Transaction != null && command.Transaction != trans)
					{
						log.Warn("The IDbCommand had a different Transaction than the Session.  This can occur when " +
						         "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific.");
					}
				}
				log.Debug("Enlist Command");

				command.Transaction = trans;
			}
		}
开发者ID:ray2006,项目名称:WCell,代码行数:46,代码来源:AdoTransaction.cs


示例6: PrepareInsertCommand

        private string PrepareInsertCommand(string sql, IDbCommand command, IEnumerable<Column> columns)
        {
            var parameterFactory = _adapter.ProviderHelper.GetCustomProvider<IDbParameterFactory>(_schemaProvider)
                                   ?? new GenericDbParameterFactory(command);

            var columnLookup = columns.ToDictionary(c => c.QuotedName, c => c);
            if (columnLookup.Count == 0) return PrepareCommand(sql, command);

            int openParenIndex = sql.IndexOf('(');
            int closeParenLength = sql.IndexOf(')') - openParenIndex;
            var columnNameList = sql.Substring(openParenIndex, closeParenLength).Trim('(', ')').Split(',');
            int index = 0;
            var sqlBuilder = new StringBuilder();
            foreach (var c in sql)
            {
                if (c == '?')
                {
                    var column = columnLookup[columnNameList[index]];
                    var parameter = parameterFactory.CreateParameter(_schemaProvider.NameParameter("p" + index), column);
                    command.Parameters.Add(parameter);
                    
                    sqlBuilder.Append(parameter.ParameterName);
                    index++;
                }
                else
                {
                    sqlBuilder.Append(c);
                }
            }
            return sqlBuilder.ToString();
        }
开发者ID:rposbo,项目名称:Simple.Data,代码行数:31,代码来源:CommandHelper.cs


示例7: DeriveParameters

		/// <summary>
		/// Populates the specified IDbCommand object's Parameters collection with 
		/// parameter information for the stored procedure specified in the IDbCommand.
		/// </summary>
		/// <remarks>
		/// See the <see cref="DbManager.AddDataProvider(DataProviderBase)"/> method to find an example.
		/// </remarks>
		/// <seealso cref="DbManager.AddDataProvider(DataProviderBase)">AddDataManager Method</seealso>
		/// <param name="command">The IDbCommand referencing the stored procedure for which the parameter information is to be derived. The derived parameters will be populated into the Parameters of this command.</param>
		public override bool DeriveParameters(IDbCommand command)
		{
			// SQLiteCommandBuilder does not implement DeriveParameters.
			// This is not surprising, since SQLite has no support for stored procs.
			//
			return false;
		}
开发者ID:devmlog,项目名称:bltoolkit,代码行数:16,代码来源:CSharpSQLiteDataProvider.cs


示例8: AttachParameter

		public override void AttachParameter(IDbCommand command, IDbDataParameter parameter)
		{
			if (parameter.DbType == DbType.DateTime2)
				parameter.DbType = DbType.DateTime;

			base.AttachParameter(command, parameter);
		}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:7,代码来源:Sql2005DataProvider.cs


示例9: Set

 void SqlMapper.ICustomQueryParameter.AddParameter(IDbCommand command, string name)
 {
     var param = command.CreateParameter();
     param.ParameterName = name;
     Set(param, table, typeName);
     command.Parameters.Add(param);
 }
开发者ID:CarlSosaDev,项目名称:dapper-dot-net,代码行数:7,代码来源:TableValuedParameter.cs


示例10: Set

		public override void Set(IDbCommand cmd, object value, int index)
		{
			if (value is EnumStoredAsString && (EnumStoredAsString)value == EnumStoredAsString.Unspecified)
				base.Set(cmd, null, index);
			else
				base.Set(cmd, value, index);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:7,代码来源:User.cs


示例11: Initialize

 public override void Initialize(IDatabaseEngine engine, IDbCommand command)
 {
     string innerParameterName = engine.GetParameterName(ParameterName);
     sqlSnippet = sqlSnippet.Replace(REPLACEMENT_VALUE, innerParameterName);
     _innerParameter = command.CreateParameter();
     _innerParameter.ParameterName = innerParameterName;
 }
开发者ID:hp4711,项目名称:structuremap,代码行数:7,代码来源:ParameterizedQueryFilter.cs


示例12: Build

 /// <summary>
 /// Execute the command and take the first cell of each row to build an Enumerable of string
 /// </summary>
 /// <param name="cmd">A sql or mdx query to execute</param>
 /// <returns>The first cell of row returned by the query</returns>
 public virtual IEnumerable<string> Build(IDbCommand cmd)
 {
     var qe = new QueryEngineFactory().GetExecutor(cmd);
     var ds = qe.Execute();
     var list = Load(ds);
     return list;
 }
开发者ID:Waltervondehans,项目名称:NBi,代码行数:12,代码来源:ListBuilder.cs


示例13: FormatSql

        /// <summary>
        /// Formats the SQL in a SQL-Server friendly way, with DECLARE statements for the parameters up top.
        /// </summary>
        public string FormatSql(string commandText, List<SqlTimingParameter> parameters, IDbCommand command = null)
        {
            StringBuilder buffer = new StringBuilder();

            if (command != null && IncludeMetaData)
            {
                buffer.AppendLine("-- Command Type: " + command.CommandType);
                buffer.AppendLine("-- Database: " + command.Connection.Database);
                if (command.Transaction != null)
                {
                    buffer.AppendLine("-- Command Transaction Iso Level: " + command.Transaction.IsolationLevel);
                }
				if (Transaction.Current != null)
				{
					// transactions issued by TransactionScope are not bound to the database command but exists globally
					buffer.AppendLine("-- Transaction Scope Iso Level: " + Transaction.Current.IsolationLevel);
				}
                buffer.AppendLine();
            }

	        string baseOutput = base.FormatSql(commandText, parameters, command);

	        buffer.Append(baseOutput);

	        return buffer.ToString();
        }
开发者ID:BiYiTuan,项目名称:dotnet,代码行数:29,代码来源:VerboseSqlServerFormatter.cs


示例14: ExecuteStartImpl

        /// <summary>
        /// Tracks when 'command' is started.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="type">The type.</param>
        public void ExecuteStartImpl(IDbCommand command, ExecuteType type)
        {
            var id = Tuple35.Create((object)command, type);
            var sqlTiming = new SqlTiming(command, type, Profiler);

            _inProgress[id] = sqlTiming;
        }
开发者ID:krk,项目名称:MiniProfiler,代码行数:12,代码来源:SqlProfiler.cs


示例15: IsXmlParameter

		/// <summary>
		/// Determines if a parameter is an XML type parameter.
		/// </summary>
		/// <param name="command">The related command object.</param>
		/// <param name="parameter">The parameter to test.</param>
		/// <returns>True if the parameter is an XML parameter.</returns>
		public override bool IsXmlParameter(IDbCommand command, IDataParameter parameter)
		{
			if (parameter == null) throw new ArgumentNullException("parameter");

			var op = (OracleParameter)parameter;
			return op.OracleDbType == OracleDbType.XmlType;
		}
开发者ID:EdWeller,项目名称:Insight.Database,代码行数:13,代码来源:OracleInsightDbProvider.cs


示例16: Script

 public void Script(IDbCommand command)
 {
     foreach (ISqlScripter scripter in _scripters)
     {
         scripter.Script(command);
     }
 }
开发者ID:mediocreguy,项目名称:MigSharp,代码行数:7,代码来源:AggregateScripter.cs


示例17: OnExecutingCommand

 protected override void OnExecutingCommand(IDbCommand cmd)
 {
     if (log.IsDebugEnabled)
     {
         log.Debug(FormatCommand(cmd));
     }
 }
开发者ID:bytefish,项目名称:GcmSample,代码行数:7,代码来源:LoggingDatabase.cs


示例18: AttachParameter

        public override void AttachParameter(IDbCommand command, IDbDataParameter parameter)
        {
            if (parameter.Value is string && parameter.DbType == DbType.Guid)
                parameter.DbType = DbType.AnsiString;

            base.AttachParameter(command, parameter);
        }
开发者ID:qrunner,项目名称:Default,代码行数:7,代码来源:SybaseAdoDataProvider.cs


示例19: CreateDataAdapter

		public static DbDataAdapter CreateDataAdapter(DbProviderType DbProviderType, IDbCommand command, IDbConnection connection)
		{
			switch (DbProviderType)
			{
				case DbProviderType.SQLSERVER:
					SqlDataAdapter sqlda = new SqlDataAdapter();
					sqlda.SelectCommand = (SqlCommand) command;
					command.Connection = connection;
					return sqlda;
				case DbProviderType.ORACLE:
					OracleDataAdapter orada = new OracleDataAdapter();
					orada.SelectCommand = (OracleCommand) command;
					command.Connection = connection;
					return orada;
//				case DbProviderType.MYSQL:
//					MySqlDataAdapter mysqlda = new MySqlDataAdapter();
//					mysqlda.SelectCommand = (MySqlCommand) command;
//					command.Connection = connection;
//					return mysqlda;
				default:
					OleDbDataAdapter oleda = new OleDbDataAdapter();
					oleda.SelectCommand = (OleDbCommand) command;
					command.Connection = connection;
					return oleda;
			}
		}
开发者ID:BackupTheBerlios,项目名称:ch3etah-svn,代码行数:26,代码来源:DbProviderFactory.cs


示例20: GetTripFormResponses

        private List<TripFormResponse> GetTripFormResponses(IDbCommand command)
        {
            var connection = _dbConnection;
            try
            {
                connection.Open();

                command.Connection = connection;
                var reader = command.ExecuteReader();
                var responses = new List<TripFormResponse>();
                while (reader.Read())
                {
                    var response = new TripFormResponse();
                    response.ContactId = reader.GetInt32(reader.GetOrdinal("Contact_ID"));
                    var donorId = SafeInt32(reader, "Donor_ID");
                    response.DonorId = donorId;
                    response.FundraisingGoal = SafeDecimal(reader,"Fundraising_Goal");
                    response.ParticipantId = reader.GetInt32(reader.GetOrdinal("Participant_ID"));
                    response.PledgeCampaignId = SafeInt32(reader, "Pledge_Campaign_ID");
                    response.EventId = SafeInt32(reader, "Event_ID");
                    response.DestinationId = reader.GetInt32(reader.GetOrdinal("Destination_ID"));

                    responses.Add(response);
                }
                return responses;
            }
            finally
            {
                connection.Close();
            }
        }
开发者ID:plachmann,项目名称:crds-angular,代码行数:31,代码来源:FormSubmissionService.cs



注:本文中的IDbCommand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IDbConnection类代码示例发布时间:2022-05-24
下一篇:
C# IDateTimeHelper类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap