예제 #1
0
        /// <summary>
        /// 解释MoreThen条件
        /// </summary>
        /// <param name="list"></param>
        /// <param name="entityType"></param>
        /// <param name="paramName"></param>
        /// <param name="type"></param>
        /// <param name="lstIndex"></param>
        public static string MoreThen(Scope scope, ParamList list, Type entityType, string paramName, DbType type, int lstIndex)
        {
            DBInfo        db            = EntityInfoManager.GetEntityHandle(entityType).DBInfo;
            string        paramVal      = db.CurrentDbAdapter.FormatValueName(DataAccessCommon.FormatParam(paramName, lstIndex));
            string        paramKey      = db.CurrentDbAdapter.FormatParamKeyName(DataAccessCommon.FormatParam(paramName, lstIndex));
            StringBuilder sql           = new StringBuilder(500);
            ScopeType     ctype         = scope.ScopeType;
            string        connectString = DataAccessCommon.GetConnectString(scope);

            if (list != null)
            {
                sql.Append(" ");
                sql.Append(connectString);
                sql.Append(" (");
                sql.Append(db.CurrentDbAdapter.FormatParam(paramName));
                sql.Append(" >= ");
                sql.Append(paramVal);
                sql.Append(")");
                list.AddNew(paramKey, type, scope.Value1);
            }
            else
            {
                sql.Append(" ");
                sql.Append(connectString);
                sql.Append(" (");
                sql.Append(db.CurrentDbAdapter.FormatParam(paramName));
                sql.Append(" >= ");
                sql.Append(DataAccessCommon.FormatValue(scope.Value1, type, db));
                sql.Append(")");
            }
            return(sql.ToString());
        }
예제 #2
0
        /// <summary>
        /// 根据数据类型自动拼合in字符串
        /// </summary>
        /// <param name="collection">值集合</param>
        /// <param name="type">类型</param>
        /// <returns></returns>
        private static string GetInString(object collection, DbType type, DBInfo info)
        {
            IEnumerable enumValues = (IEnumerable)collection;
            string      ret        = "";

            foreach (object item in enumValues)
            {
                ret += DataAccessCommon.FormatValue(item, type, info) + ",";
            }
            if (ret.Length > 0)
            {
                ret = ret.Substring(0, ret.Length - 1);
            }
            return(ret);
        }