Пример #1
0
        /// <summary>
        /// INSERT INTO (...) SELECT ...
        /// </summary>
        public static int Insert <T, STFrom, ST>(this IQueryRunner runner, FromQuery <T> query, Query <STFrom, ST> subQuery, Expression <Action <ST, InsertBuilder <T> > > insertExpr) where T : new()
        {
            var stmtList = new StatementList();

            stmtList.Insert(query, subQuery, insertExpr);
            return(runner.ExecuteNonQuery(stmtList));
        }
Пример #2
0
 public InsertSelectStatement(FromQuery <T> parent, Query <STFrom, ST> insertSelectQuery, Expression <Action <ST, InsertBuilder <T> > > insertExpr)
 {
     FromQuery        = parent;
     SelectQuery      = insertSelectQuery;
     InsertExpression = insertExpr;
     InsertFunction   = insertExpr.Compile();
 }
Пример #3
0
        public int EvaluateInMemory(InMemoryQueryRunner runner, out int identity)
        {
            var builder = new InsertBuilder <T>();

            InsertFunction(builder);
            FromQuery.InsertImpl(builder, out identity);
            return(1);
        }
Пример #4
0
        /// <summary>
        /// INSERT INTO (...) VALUES ( ...); SELECT LAST_IDENTITY()
        /// </summary>
        public static TIdentity Insert <T, TIdentity>(this IQueryRunner runner, FromQuery <T> query, Expression <Action <InsertBuilder <T> > > insertExpr) where T : new()
        {
            var stmtList = new StatementList();

            stmtList.Insert(query, insertExpr);
            var select = stmtList.Select(ctx => Function.LastInsertIdentity <TIdentity>(ctx));

            return(runner.ExecuteQuery(select).FirstOrDefault());
        }
Пример #5
0
        public int EvaluateInMemory(IQueryRunner runner)
        {
            var lastNonQueryResult = 0;

            var items = Parent.InMemorySelect(runner);

            foreach (var item in items)
            {
                var fromRow = Parent.FromRowMapping[item];
                var builder = new InsertBuilder <T>();
                InsertFunction(item, builder);

                FromQuery.UpdateObject(fromRow, builder.BuilderType, builder);
                lastNonQueryResult++;
            }

            return(lastNonQueryResult);
        }
Пример #6
0
        public int EvaluateInMemory(InMemoryQueryRunner runner, out int identity)
        {
            var lastNonQueryResult = 0;

            identity = 0;

            var items = SelectQuery.InMemorySelect(runner);

            foreach (var item in items)
            {
                var builder = new InsertBuilder <T>();
                InsertFunction(item, builder);

                FromQuery.InsertImpl(builder, out identity);
                lastNonQueryResult++;
            }

            return(lastNonQueryResult);
        }
Пример #7
0
 public DeleteStatement(FlatQuery <T, TJoin> parent)
 {
     Parent    = parent;
     FromQuery = parent.GetFromQuery <T>();
 }
Пример #8
0
 public InsertStatement(FromQuery <T> parent, Expression <Action <InsertBuilder <T> > > insertExpr)
 {
     FromQuery        = parent;
     InsertExpression = insertExpr;
     InsertFunction   = insertExpr.Compile();
 }
Пример #9
0
 /// <summary>
 /// INSERT INTO (...) VALUES ( ...)
 /// </summary>
 public void Insert <T>(FromQuery <T> query, Expression <Action <InsertBuilder <T> > > insertExpr) where T : new()
 {
     Queries.Add(new InsertStatement <T>(query, insertExpr));
 }
Пример #10
0
 /// <summary>
 /// INSERT INTO (...) SELECT ...
 /// </summary>
 public void Insert <T, STFrom, ST>(FromQuery <T> query, Query <STFrom, ST> subQuery, Expression <Action <ST, InsertBuilder <T> > > insertExpr) where T : new()
 {
     Queries.Add(new InsertSelectStatement <T, STFrom, ST>(query, subQuery, insertExpr));
 }