Example #1
0
        string GetInsertValueSql(DatabaseProvider provider)
        {
            var table = _tables[0];
            var cols  = table.GetInsertColumns();

            if (cols.Count == 0)
            {
                return(null);
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("(");
            for (int i = 0; i < cols.Count; i++)
            {
                var col = cols[i];
                if (col._isPrimaryKey && col._isAutoIncrement)
                {
                    continue;
                }
                if ("boolean|int16|int32|int64|uint16|uint32|uint64|single|double|decimal".Contains(col._fieldType) == false)
                {
                    if (col._changeType == Enums.ColumnChangeType.None)
                    {
                        continue;
                    }
                }
                var obj = provider.EscapeParam(col.GetValue());
                stringBuilder.Append(obj);
                stringBuilder.Append(",");
            }
            stringBuilder[stringBuilder.Length - 1] = ')';
            return(stringBuilder.ToString());
        }
Example #2
0
 /// <summary>
 /// 转SQL语句
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="tableCount"></param>
 /// <returns></returns>
 protected internal override string ToSql(DatabaseProvider provider, int tableCount)
 {
     if (isSetValaue == false)
     {
         return((leftColumn).ToSql(provider, tableCount) + " " + op);
     }
     return((leftColumn).ToSql(provider, tableCount) + " " + op + " "
            + provider.EscapeParam(value));
 }
Example #3
0
 /// <summary>
 /// 转SQL语句
 /// </summary>
 /// <param name="stringBuilder"></param>
 /// <param name="provider"></param>
 /// <param name="tableCount"></param>
 protected internal override void ToSql(StringBuilder stringBuilder, DatabaseProvider provider, int tableCount)
 {
     stringBuilder.Append((leftColumn).ToSql(provider, tableCount));
     stringBuilder.Append(" ");
     stringBuilder.Append(op);
     if (isSetValaue)
     {
         stringBuilder.Append(" ");
         stringBuilder.Append(provider.EscapeParam(value));
     }
 }
Example #4
0
        string GetUpdateWhere(DatabaseProvider provider)
        {
            var where = GetWhere(provider);
            if (string.IsNullOrEmpty(where) == false)
            {
                return(where);
            }
            var table = _tables[0];

            if (table.IsSetPrimaryKey())
            {
                var pk = table.GetPrimaryKey();
                if (pk._changeType == Enums.ColumnChangeType.NewValue)
                {
                    return(pk.ToSql(provider, _tables.Count) + " = " + provider.EscapeParam(pk.GetValue()));
                }
                return(pk.ToSql(provider, _tables.Count) + " = " + pk.GetNewValue().ToSql(provider, _tables.Count));
            }
            throw new ArgumentNullException("where is not set!");
        }