Ejemplo n.º 1
0
 public FilterTableVisitor(List <string> allTableSuffixs, ShardingRule rule)
 {
     _allTableSuffixs = allTableSuffixs;
     _rule            = rule;
 }
Ejemplo n.º 2
0
        public static List <string> FilterTable(IQueryable queryable, List <string> tableSuffixs, ShardingRule rule)
        {
            FilterTableVisitor visitor = rule.ShardingType switch
            {
                ShardingType.HashMod => new FilterTableByHashModVisitor(tableSuffixs, rule),
                ShardingType.Date => new FilterTableByDateVisitor(tableSuffixs, rule),
                _ => throw new Exception("ShardingType无效")
            };

            visitor.Visit(queryable.Expression);

            return(visitor.GetResTables());
        }