Esempio n. 1
0
        /// <summary>
        /// INSERT INTO table_name
        /// (column1, column2, column3,...)
        /// VALUES(value1, value2, value3,...)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public InsertStatement Insert <T>(T obj)
        {
            InsertStatement statement = null;

            if (obj is IEnumerable)
            {
                var enumerator = ((IEnumerable)obj).GetEnumerator();

                while (enumerator.MoveNext())
                {
                    if (statement == null)
                    {
                        statement = new InsertStatement(new Table(enumerator.Current.GetType()));
                    }

                    statement.ObjectList.Add(enumerator.Current);
                }
            }
            else
            {
                statement = new InsertStatement(new Table(typeof(T)));
                statement.ObjectList.Add(obj);
            }

            Statement = statement;

            return(statement);
        }
Esempio n. 2
0
        /// <summary>
        /// INSERT INTO table_name
        /// (column1, column2, column3,...)
        /// VALUES(value1, value2, value3,...)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <returns></returns>
        public InsertStatement Insert <T>(T obj) where T : class, new()
        {
            var statement = new InsertStatement(new Table <T>());

            statement.ObjectList.Add(obj);
            Statement = statement;

            return(statement);
        }
Esempio n. 3
0
        /// <summary>
        /// INSERT INTO table_name
        /// (column1, column2, column3,...)
        /// VALUES(value1, value2, value3,...)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="objects"></param>
        /// <returns></returns>
        public InsertStatement InsertMany <T>(IEnumerable <T> objects) where T : class, new()
        {
            var statement  = new InsertStatement(new Table <T>());
            var enumerator = objects.GetEnumerator();

            while (enumerator.MoveNext())
            {
                statement.ObjectList.Add(enumerator.Current);
            }

            Statement = statement;

            return(statement);
        }