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);
        }
Exemple #2
0
        public override IBatch End()
        {
            IBatch        batch = new MysqlBatch();
            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 (!String.IsNullOrEmpty(Reduce.GetTop().ColumnName))
            {
                sb.Append($" limit 0, @{Reduce.GetTop().ColumnName} ");
            }
            batch.SqlBuilder        = sb.ToString();
            batch.DynamicParameters = Reduce.Parameters;
            return(batch);
        }