Ejemplo n.º 1
0
        /// <summary>
        /// Builds an SqlQuery to insert a database record for the specified instance with the current property values of the instance.
        /// </summary>
        /// <param name="objectInfo">The object information.</param>
        /// <param name="instance">The instance to insert.</param>
        /// <returns>
        /// The created <see cref="SqlQuery" />.
        /// </returns>
        public SqlQuery BuildInsertSqlQuery(IObjectInfo objectInfo, object instance)
        {
            if (objectInfo == null)
            {
                throw new ArgumentNullException("objectInfo");
            }

            if (log.IsDebug)
            {
                log.Debug(LogMessages.SqlDialect_CreatingSqlQuery, "INSERT");
            }

            string insertCommand;

            if (!this.insertCommandCache.TryGetValue(objectInfo.ForType, out insertCommand))
            {
                insertCommand = this.BuildInsertCommandText(objectInfo);

                var newInsertCommandCache = new Dictionary <Type, string>(this.insertCommandCache);
                newInsertCommandCache[objectInfo.ForType] = insertCommand;

                this.insertCommandCache = newInsertCommandCache;
            }

            var insertValues = objectInfo.GetInsertValues(instance);

            return(new SqlQuery(insertCommand, insertValues));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds an SqlQuery to insert a database record for the specified instance with the current property values of the instance.
        /// </summary>
        /// <param name="objectInfo">The object information.</param>
        /// <param name="instance">The instance to insert.</param>
        /// <returns>
        /// The created <see cref="SqlQuery" />.
        /// </returns>
        public SqlQuery BuildInsertSqlQuery(IObjectInfo objectInfo, object instance)
        {
            if (objectInfo == null)
            {
                throw new ArgumentNullException("objectInfo");
            }

            string insertCommand;

            if (!this.insertCommandCache.TryGetValue(objectInfo.ForType, out insertCommand))
            {
                var commandText = this.BuildInsertCommandText(objectInfo);

                var newInsertCommandCache = new Dictionary<Type, string>(this.insertCommandCache);
                newInsertCommandCache[objectInfo.ForType] = commandText;
                insertCommand = commandText;

                this.insertCommandCache = newInsertCommandCache;
            }

            var insertValues = objectInfo.GetInsertValues(instance);

            return new SqlQuery(insertCommand, insertValues);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Builds an SqlQuery to insert a database record for the specified instance with the current property values of the instance.
        /// </summary>
        /// <param name="objectInfo">The object information.</param>
        /// <param name="instance">The instance to insert.</param>
        /// <returns>
        /// The created <see cref="SqlQuery" />.
        /// </returns>
        public SqlQuery BuildInsertSqlQuery(IObjectInfo objectInfo, object instance)
        {
            if (objectInfo == null)
            {
                throw new ArgumentNullException("objectInfo");
            }

            if (log.IsDebug)
            {
                log.Debug(LogMessages.SqlDialect_CreatingSqlQuery, "INSERT");
            }

            string insertCommand;

            if (!this.insertCommandCache.TryGetValue(objectInfo.ForType, out insertCommand))
            {
                insertCommand = this.BuildInsertCommandText(objectInfo);

                var newInsertCommandCache = new Dictionary<Type, string>(this.insertCommandCache);
                newInsertCommandCache[objectInfo.ForType] = insertCommand;

                this.insertCommandCache = newInsertCommandCache;
            }

            var insertValues = objectInfo.GetInsertValues(instance);

            return new SqlQuery(insertCommand, insertValues);
        }