Exemplo n.º 1
0
        static bool IsCanRemoveCache(AopEnum action, AopInfo aopInfo)
        {
            if (IngoreCacheColumns.Count > 0)
            {
                string databaseName = string.Empty;
                if (action == AopEnum.ExeNonQuery)
                {
                    if (aopInfo.IsProc || !aopInfo.ProcName.ToLower().StartsWith("update "))
                    {
                        return(true);
                    }
                    databaseName = aopInfo.MProc.DataBase;
                }
                else
                {
                    databaseName = aopInfo.MAction.DataBase;
                }
                string tableName = aopInfo.TableName;
                if (string.IsNullOrEmpty(tableName))
                {
                    List <string> tableNames = SqlFormat.GetTableNamesFromSql(aopInfo.ProcName);
                    if (tableNames == null || tableNames.Count != 1)//多个表的批量语句也不处理。
                    {
                        return(true);
                    }
                    tableName = tableNames[0];
                }
                //获取被更新的字段名,
                string[] columns = null;
                if (IngoreCacheColumns.ContainsKey(tableName))
                {
                    columns = IngoreCacheColumns[tableName].ToLower().Split(',');
                }
                else if (IngoreCacheColumns.ContainsKey(databaseName + "." + tableName))
                {
                    columns = IngoreCacheColumns[databaseName + "." + tableName].ToLower().Split(',');
                }
                if (columns != null)                                                  //拿到要忽略的列。
                {
                    List <string> updateColumns = GetChangedColumns(action, aopInfo); //拿到已更新的列
                    if (columns.Length >= updateColumns.Count)
                    {
                        List <string> ignoreColumns = new List <string>(columns.Length);
                        ignoreColumns.AddRange(columns);

                        foreach (string item in updateColumns)
                        {
                            if (!ignoreColumns.Contains(item))
                            {
                                return(true);//只要有一个不存在。
                            }
                        }
                        return(false);//全都不存在
                    }
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        private static List <string> GetRelationTables(AopInfo para)
        {
            List <string> tables = null;

            if (para.MAction != null)
            {
                tables = para.MAction.Data.Columns.relationTables;
            }
            else if (para.MProc != null && !para.IsProc)
            {
                if (para.Table != null)
                {
                    tables = para.Table.Columns.relationTables;
                }
                else
                {
                    tables = SqlFormat.GetTableNamesFromSql(para.ProcName);
                }
            }
            return(tables);
        }