Esempio n. 1
0
        internal R Insert <R>(IQueryable query, LambdaExpression constructor, ITable table, Func <SqlPreCommandSimple, R> continuation, bool removeSelectRowCount = false)
        {
            AliasGenerator aliasGenerator = new AliasGenerator();

            SqlPreCommandSimple cr;

            using (HeavyProfiler.Log("LINQ"))
                using (var log = HeavyProfiler.LogNoStackTrace("Clean"))
                {
                    Expression cleaned = Clean(query.Expression, true, log) !;
                    var        binder  = new QueryBinder(aliasGenerator);
                    log.Switch("Bind");
                    CommandExpression insert           = binder.BindInsert(cleaned, constructor, table);
                    CommandExpression insertOprimized  = (CommandExpression)Optimize(insert, binder, aliasGenerator, log);
                    CommandExpression insertSimplified = CommandSimplifier.Simplify(insertOprimized, removeSelectRowCount, aliasGenerator);
                    log.Switch("TR");
                    cr = TranslatorBuilder.BuildCommandResult(insertSimplified);
                }
            return(continuation(cr));
        }