private List <IRouteValue> GetDatabaseShardingValues(ShardingRule shardingRule, TableRule tableRule, ShardingCondition shardingCondition)
        {
            var dataBaseShardingStrategy = shardingRule.GetDatabaseShardingStrategy(tableRule);

            return(IsGettingShardingValuesFromHint(dataBaseShardingStrategy)
                    ? GetDatabaseShardingValuesFromHint() : GetShardingValuesFromShardingConditions(shardingRule, dataBaseShardingStrategy.GetShardingColumns(), shardingCondition));
        }
 private ICollection <DataNode> RouteByMixedConditionsWithHint(ShardingRule shardingRule, TableRule tableRule)
 {
     if (shardingRule.GetDatabaseShardingStrategy(tableRule) is HintShardingStrategy)
     {
         return(Route0(shardingRule, tableRule, GetDatabaseShardingValuesFromHint(), new List <IRouteValue>(0)));
     }
     return(Route0(shardingRule, tableRule, new ArrayList <IRouteValue>(0), GetTableShardingValuesFromHint()));
 }
        private ICollection <string> RouteDataSources(ShardingRule shardingRule, TableRule tableRule, List <IRouteValue> databaseShardingValues)
        {
            if (databaseShardingValues.IsEmpty())
            {
                return(tableRule.GetActualDatasourceNames());
            }
            ICollection <string> result = new HashSet <string>(shardingRule.GetDatabaseShardingStrategy(tableRule).DoSharding(tableRule.GetActualDatasourceNames(), databaseShardingValues, this.Properties));

            ShardingAssert.If(result.IsEmpty(), "no database route info");
            ShardingAssert.Else(tableRule.GetActualDatasourceNames().All(o => result.Contains(o)), $"Some routed data sources do not belong to configured data sources. routed data sources: `{result}`, configured data sources: `{tableRule.GetActualDatasourceNames()}`");

            return(result);
        }
        private ICollection <DataNode> RouteByShardingConditionsWithCondition(ShardingRule shardingRule, TableRule tableRule)
        {
            ICollection <DataNode> result = new LinkedList <DataNode>();

            foreach (var condition in ShardingConditions.Conditions)
            {
                ICollection <DataNode> dataNodes = Route0(shardingRule, tableRule,
                                                          GetShardingValuesFromShardingConditions(shardingRule, shardingRule.GetDatabaseShardingStrategy(tableRule).GetShardingColumns(), condition),
                                                          GetShardingValuesFromShardingConditions(shardingRule, shardingRule.GetTableShardingStrategy(tableRule).GetShardingColumns(), condition));
                result.AddAll(dataNodes);
                OriginalDataNodes.Add(dataNodes);
            }
            return(result);
        }
 private bool IsRoutingByShardingConditions(ShardingRule shardingRule, TableRule tableRule)
 {
     return(!(shardingRule.GetDatabaseShardingStrategy(tableRule) is HintShardingStrategy || shardingRule.GetTableShardingStrategy(tableRule) is HintShardingStrategy));
 }
 private bool IsRoutingByHint(ShardingRule shardingRule, TableRule tableRule)
 {
     return(shardingRule.GetDatabaseShardingStrategy(tableRule) is HintShardingStrategy && shardingRule.GetTableShardingStrategy(tableRule) is HintShardingStrategy);
 }