Пример #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>
        /// 填充查询条件并返回条件的SQL语句( and 开头)
        /// </summary>
        /// <param name="lstParam">参数列表</param>
        /// <param name="lstScope">范围查询集合</param>
        /// <param name="CurEntityInfo">当前实体信息</param>
        /// <param name="index">索引</param>
        /// <returns></returns>
        internal static string FillCondition(EntityInfoHandle curEntityInfo, ParamList lstParam, ScopeList lstScope, ref int index)
        {
            if (lstScope == null)
            {
                return("");
            }
            StringBuilder ret = new StringBuilder();

            for (int i = 0; i < lstScope.Count; i++)
            {
                Scope objScope          = lstScope[i];
                EntityPropertyInfo info = null;
                if (!string.IsNullOrEmpty(objScope.PropertyName))
                {
                    info = curEntityInfo.PropertyInfo[objScope.PropertyName];
                }

                if (objScope.ScopeType == ScopeType.Scope)
                {
                    ScopeList lstInnerScope = objScope.Value1 as ScopeList;
                    if (lstInnerScope != null)
                    {
                        string        strSql        = FillCondition(curEntityInfo, lstParam, lstInnerScope, ref index);
                        string        connectString = DataAccessCommon.GetConnectString(objScope);
                        StringBuilder sbstrSQL      = new StringBuilder(strSql);
                        DataAccessCommon.TrimAnd(sbstrSQL);
                        ret.Append(" ");
                        ret.Append(connectString);
                        ret.Append(" (" + sbstrSQL.ToString() + ")");
                    }
                }
                else
                {
                    string pName  = (info != null ? info.ParamName : "");
                    DbType dbType = (info != null ? info.SqlType : DbType.Object);
                    ret.Append(FormatScorp(objScope, lstParam, pName, dbType, index, curEntityInfo.EntityType));
                }
                index++;
            }
            return(ret.ToString());
        }