コード例 #1
0
 void GetCondition <T>(string col, T val, string andor = AndOr.And, string op = Op.Eq, bool isFunc = false)
 {
     if (IsKeyCondition)
     {
         return;
     }
     if (string.IsNullOrWhiteSpace(col))
     {
         return;
     }
     // 如果有左括号,忽略逻辑运算符
     if (hasParenthesis)
     {
         hasParenthesis = false;
     }
     else if (OtherCondition.Length > 0)
     {
         OtherCondition.Append(andor);
     }
     if (isFunc)
     {
         OtherCondition.Append(DB.SetColumnFunc(col, val));
     }
     else
     {
         OtherCondition.Append(DB.GetCondition(col, op));
         Params.Add(DB.GetParam(col, val));
     }
 }
コード例 #2
0
 /// <summary>
 /// 将列更新为计算值
 /// </summary>
 /// <param name="col">列名</param>
 /// <param name="formula">计算公式</param>
 /// <returns></returns>
 public Sql SetFunc(string col, string formula)
 {
     _SetColumns.Add(DB.SetColumnFunc(col, formula));
     return(this);
 }
コード例 #3
0
        /// <summary>
        /// 读取指定id的指定列数据
        /// </summary>
        /// <param name="id"></param>
        /// <param name="col">列名</param>
        /// <returns></returns>
        public object GetSingle(long id, string col)
        {
            if (id < 0)
            {
                return(null);
            }
            var _sql = string.Concat("SELECT ", DB.GetName(col), FromTableString, " WHERE ", DB.SetColumnFunc("id", id), " limit 1;");

            return(Db.ReadSingle(_sql));
        }
コード例 #4
0
        /// <summary>
        /// 读取实时数据对象
        /// </summary>
        /// <param name="id">主键</param>
        /// <param name="args">返回的字段</param>
        /// <returns></returns>
        public T Get(long id, params string[] args)
        {
            if (id < 0)
            {
                return(null);
            }
            var _sql = string.Concat("SELECT ", args.Length == 0 ? SelectColumnString : GetSelectColumnStringByArgs(args), FromTableString, " WHERE ", DB.SetColumnFunc("id", id), " limit 1;");

            return(_Get(_sql, null, args));
        }