コード例 #1
0
        /// <summary>
        /// 解释Condition条件
        /// </summary>
        /// <param name="scope">条件</param>
        /// <param name="list"></param>
        /// <param name="entityType"></param>
        /// <param name="paramName"></param>
        /// <param name="type"></param>
        /// <param name="lstIndex"></param>
        public static string Condition(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);

            BQLCondition fhandle = scope.Value1 as BQLCondition;

            if (!CommonMethods.IsNull(fhandle))
            {
                KeyWordInfomation info = new KeyWordInfomation();
                info.Infos  = new Buffalo.DB.BQLCommon.BQLInfos();
                info.DBInfo = db;

                info.ParamList = list;
                sql.Append(" ");
                sql.Append(connectString);

                sql.Append(" (" + fhandle.DisplayValue(info) + ")");
            }
            return(sql.ToString());
        }
コード例 #2
0
        /// <summary>
        /// 解释EndWith条件
        /// </summary>
        /// <param name="list"></param>
        /// <param name="entityType"></param>
        /// <param name="paramName"></param>
        /// <param name="type"></param>
        /// <param name="lstIndex"></param>
        public static string EndWith(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(" (" + db.CurrentDbAdapter.FormatParam(paramName) + " like " + db.CurrentDbAdapter.ConcatString("'%'", paramVal) + ")");
                list.AddNew(paramKey, type, scope.Value1);
            }
            else
            {
                sql.Append(" ");
                sql.Append(connectString);
                string curValue = scope.Value1.ToString();
                sql.Append(" (" + db.CurrentDbAdapter.FormatParam(paramName) + " like '%" + scope.Value1 + "')");
            }
            return(sql.ToString());
        }
コード例 #3
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());
        }
コード例 #4
0
        /// <summary>
        /// 解释NotIN条件(如果集合为空,则返回1=1)
        /// </summary>
        /// <param name="list"></param>
        /// <param name="entityType"></param>
        /// <param name="paramName"></param>
        /// <param name="type"></param>
        /// <param name="lstIndex"></param>
        public static string NotIN(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);
            string        inValue       = null;

            inValue = GetInString(scope.Value1, type, db);
            if (inValue != "" && inValue != null)
            {
                sql.Append(" ");
                sql.Append(connectString);
                sql.Append(" (");
                sql.Append(db.CurrentDbAdapter.FormatParam(paramName));
                sql.Append(" not in (");
                sql.Append(inValue);
                sql.Append("))");
            }
            else //没有数据时候设置改条件不成立
            {
                sql.Append(" ");
                sql.Append(connectString);
                sql.Append(" 1=1");
            }
            return(sql.ToString());
        }
コード例 #5
0
        /// <summary>
        /// 解释Contains条件
        /// </summary>
        /// <param name="list"></param>
        /// <param name="entityType"></param>
        /// <param name="paramName"></param>
        /// <param name="type"></param>
        /// <param name="lstIndex"></param>
        public static string Contains(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);

            sql.Append(FullTextConfigManager.GetLikeSql(scope, list, paramName, type, lstIndex, entityType, connectString, true));
            return(sql.ToString());
        }
コード例 #6
0
        /// <summary>
        /// 填充版本控制的信息
        /// </summary>
        /// <param name="where"></param>
        /// <param name="where"></param>
        /// <param name="info"></param>
        /// <param name="list"></param>
        /// <param name="curValue"></param>
        protected internal void FillWhereConcurrency(StringBuilder where,
                                                     EntityPropertyInfo info, ParamList list, object curValue, ref int index)
        {
            string paramValW = EntityInfo.DBInfo.CurrentDbAdapter.FormatValueName(DataAccessCommon.FormatParam(info.ParamName, index));
            string paramKeyW = EntityInfo.DBInfo.CurrentDbAdapter.FormatParamKeyName(DataAccessCommon.FormatParam(info.ParamName, index));

            index++;
            if (DefaultType.IsDefaultValue(curValue))
            {
                throw new Exception("版本控制字段:" + info.PropertyName + " 必须有当前版本值");
            }
            where.Append(" and ");
            where.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatParam(info.ParamName));
            where.Append("=");
            where.Append(paramValW);
            list.AddNew(paramKeyW, info.SqlType, curValue);
        }
コード例 #7
0
        private object FillUpdateConcurrency(StringBuilder sql,
                                             EntityPropertyInfo info, ParamList list, object curValue, ref int index)
        {
            object newValue = NewConcurrencyValue(curValue);

            if (newValue != null)
            {
                string paramValV = EntityInfo.DBInfo.CurrentDbAdapter.FormatValueName(DataAccessCommon.FormatParam(info.ParamName, index));
                string paramKeyV = EntityInfo.DBInfo.CurrentDbAdapter.FormatParamKeyName(DataAccessCommon.FormatParam(info.ParamName, index));

                sql.Append(",");
                sql.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatParam(info.ParamName));
                sql.Append("=");
                sql.Append(paramValV);
                list.AddNew(paramKeyV, info.SqlType, newValue);
                index++;
            }
            return(newValue);
        }