/// <summary>
 ///
 /// </summary>
 /// <param name="tablename"></param>
 /// <returns></returns>
 public QuerySQLHelper AddTable(TableRelevanceMapper table)
 {
     if (table != null)
     {
         Table.Add(table);
     }
     return(this);
 }
Beispiel #2
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 #3
0
 public RenewalSqlHelper()
 {
     Header = new List <ColumnRelevanceMapper>();
     Table  = new TableRelevanceMapper();
     Where  = new List <ColumnRelevanceMapper>();
 }