Beispiel #1
0
        public override IBatch End()
        {
            IBatch batch = new MysqlBatch();
            Tuple <List <String>, List <String> > tuple = ConvertHeader(Reduce.GetHeader());
            Type                         t            = typeof(T);
            StringBuilder                sb           = new StringBuilder();
            TableRelevanceMapper         table        = Reduce.GetTable();
            List <ColumnRelevanceMapper> wherecolumns = Reduce.GetWhere();

            sb.Append(table.TableOperatorEnum.GetOperator());
            sb.Append($" {EntityTableMapper.GetTableName(t)} ");
            switch (table.TableOperatorEnum)
            {
            case TableOperatorEnum.Insert:
                sb.Append(GetInsertSql(tuple));
                break;

            case TableOperatorEnum.Update:
                sb.Append(" set ");
                sb.Append(GetUpdateSql(tuple));
                if (wherecolumns.Count == 0)
                {
                    SetNoneWhere(t);
                }
                break;

            case TableOperatorEnum.Delete:
                if (wherecolumns.Count == 0)
                {
                    SetNoneWhere(t);
                }
                break;

            default:
                throw new Exception("请先选择操作种类");
            }
            String where = ConvertToWhere(wherecolumns);
            if (!String.IsNullOrEmpty(where))
            {
                sb.Append($" where {where}");
            }
            batch.SqlBuilder        = sb.ToString();
            batch.DynamicParameters = Reduce.Parameters;
            return(batch);
        }
Beispiel #2
0
        public override IBatch End()
        {
            IBatch        batch = new SqlServerBatch();
            StringBuilder sb    = new StringBuilder();
            String        query = ConvertToQuery(Reduce.GetQuery());
            String        table = ConvertToTable(Reduce.GetTable());

            String where = ConvertToWhere(Reduce.GetWhere());
            sb.Append($"select {query} ");
            sb.Append($"from {table} ");
            if (!String.IsNullOrEmpty(where))
            {
                sb.Append($"where {where} ");
            }
            if (Reduce.GetTop() != null)
            {
                sb.Append($" limit 0, @{Reduce.GetTop().ColumnName} ");
            }
            batch.SqlBuilder        = sb.ToString();
            batch.DynamicParameters = Reduce.Parameters;
            return(batch);
        }