예제 #1
0
        /// <summary>
        /// Insert one register in database.
        /// </summary>
        /// <param name="parTagInfo">Item to delete</param>
        /// <param name="transaction">Transaction context</param>
        /// <param name="errorMessage">Error message</param>
        public virtual void InsertOne(TagInfo parTagInfo, DbTransaction transaction, out string errorMessage)
        {
            errorMessage = null;
            try
            {
                motor.CommandText = GetInsertCommand();
                ///Warning: performance issues with this automation. See method description for details.
                List <DbParameter> paramList = ParameterBuilder.GetParametersForInsert(typeof(TagInfo), parTagInfo, motor.Command);
                motor.ClearCommandParameters();
                motor.AddCommandParameters(paramList);
                motor.AddTransaction(transaction);


                if (GetIdentity == true)
                {
                    parTagInfo.TagID = motor.ExecuteScalar();
                }
                else
                {
                    motor.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
            }
        }