/// <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)); }
public InsertSelectStatement(FromQuery <T> parent, Query <STFrom, ST> insertSelectQuery, Expression <Action <ST, InsertBuilder <T> > > insertExpr) { FromQuery = parent; SelectQuery = insertSelectQuery; InsertExpression = insertExpr; InsertFunction = insertExpr.Compile(); }
public int EvaluateInMemory(InMemoryQueryRunner runner, out int identity) { var builder = new InsertBuilder <T>(); InsertFunction(builder); FromQuery.InsertImpl(builder, out identity); return(1); }
/// <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()); }
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); }
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); }
public DeleteStatement(FlatQuery <T, TJoin> parent) { Parent = parent; FromQuery = parent.GetFromQuery <T>(); }
public InsertStatement(FromQuery <T> parent, Expression <Action <InsertBuilder <T> > > insertExpr) { FromQuery = parent; InsertExpression = insertExpr; InsertFunction = insertExpr.Compile(); }
/// <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)); }
/// <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)); }