Exemplo n.º 1
0
        public override string BuildSql(SqlOptions sqlOptions)
        {
            if (sqlOptions == null)
            {
                throw new ArgumentException(nameof(sqlOptions));
            }

            CheckBeforeBuild(sqlOptions);
            IEnumerable <SqlBuilderEntity> data = new SqlBuilderEntity[]
            {
                CustomBlocks[SqlInsertPosition.Start],
                InsertIntoBlock,
                CustomBlocks[SqlInsertPosition.Into],
                InsertColumnsBlock,
                InsertValuesBlock,
                CustomBlocks[SqlInsertPosition.Values],
                ConflictUpdate,
                CustomBlocks[SqlInsertPosition.Conflict],
                DoUpdateBlock,
                DoNothingBlock,
                CustomBlocks[SqlInsertPosition.Do],
                WhereBlock,
                CustomBlocks[SqlInsertPosition.Where],
                ReturningBlock,
                CustomBlocks[SqlInsertPosition.Return],
            };
            var commands = data.Where(b => CheckBlock(b, sqlOptions)).Select(b => b.BuildSql(sqlOptions, FlowOptions.Construct(this)));

            return(string.Join(sqlOptions.NewLine(), commands));
        }
Exemplo n.º 2
0
        public override string BuildSql(SqlOptions sqlOptions)
        {
            if (sqlOptions == null)
            {
                throw new ArgumentException(nameof(sqlOptions));
            }

            CheckBeforeBuild(sqlOptions);
            IEnumerable <SqlBuilderEntity> data = new SqlBuilderEntity[]
            {
                CustomSqlBlocks[SqlSelectPosition.Start],
                SelectValuesBlock,
                CustomSqlBlocks[SqlSelectPosition.Select],
                FromTablesBlock,
                CustomSqlBlocks[SqlSelectPosition.From],
                JoinsBlock,
                CustomSqlBlocks[SqlSelectPosition.Join],
                WhereBlock,
                CustomSqlBlocks[SqlSelectPosition.Where],
                OrdersBlock,
                CustomSqlBlocks[SqlSelectPosition.Order],
                OffsetBlock,
                CustomSqlBlocks[SqlSelectPosition.Offset],
                LimitBlock,
                CustomSqlBlocks[SqlSelectPosition.Limit]
            };
            var commands = data.Where(b => CheckBlock(b, sqlOptions)).Select(b => b.BuildSql(sqlOptions, FlowOptions.Construct(this)));

            return(string.Join(sqlOptions.NewLine(), commands));
        }
Exemplo n.º 3
0
        public override string BuildSql(SqlOptions sqlOptions)
        {
            if (sqlOptions == null)
            {
                throw new ArgumentException(nameof(sqlOptions));
            }

            CheckBeforeBuild(sqlOptions);

            IEnumerable <SqlBuilderEntity> data = new SqlBuilderEntity[]
            {
                CustomBlocks[SqlUpdatePosition.Start],
                UpdateTableBlock,
                CustomBlocks[SqlUpdatePosition.Table],
                ColumnsBlock,
                CustomBlocks[SqlUpdatePosition.Columns],
                WhereBlock,
                CustomBlocks[SqlUpdatePosition.Where],
                ReturningsBlock,
                CustomBlocks[SqlUpdatePosition.Return]
            };
            var commands = data.Where(b => CheckBlock(b, sqlOptions)).Select(b => b.BuildSql(sqlOptions, FlowOptions.Construct(this)));

            return(string.Join(sqlOptions.NewLine(), commands));
        }
Exemplo n.º 4
0
        public override string BuildSql(SqlOptions sqlOptions)
        {
            if (sqlOptions == null)
            {
                throw new ArgumentException(nameof(sqlOptions));
            }

            var updatedSqlOptions = ((SqlOptions)sqlOptions.Clone()).WithoutTableNames();

            CheckBeforeBuild(updatedSqlOptions);
            IEnumerable <SqlBuilderEntity> data = new SqlBuilderEntity[]
            {
                CustomBlocks[SqlDeletePosition.Start],
                DeleteFromBlock,
                CustomBlocks[SqlDeletePosition.From],
                WhereBlock,
                CustomBlocks[SqlDeletePosition.Where],
                ReturningsBlock,
                CustomBlocks[SqlDeletePosition.Return]
            };
            var commands = data.Where(b => CheckBlock(b, updatedSqlOptions)).Select(b => b.BuildSql(updatedSqlOptions, FlowOptions.Construct(this)));

            return(string.Join(sqlOptions.NewLine(), commands));
        }
Exemplo n.º 5
0
 public static FlowOptions Construct(SqlBuilderEntity _)
 {
     return(new FlowOptions());
 }