Exemplo n.º 1
0
        void IAddAbstractTable.AddAbsTable(string absTableName, Action <IAddPhysicTable> physicTableBuilder, Func <object, string> findTable)
        {
            IAddPhysicTable physicBuilder = new ShardingConfigBootstrapper();

            physicTableBuilder(physicBuilder);
            var value = physicBuilder.GetPropertyValue("_physicTables") as List <(string physicTableName, string dataSourceName)>;

            _absTables.Add(new AbstractTable
            {
                AbsTableName = absTableName,
                FindTable    = findTable,
                PhysicTables = value
            });

            //动态实体模型
            var absEntityType = DbModelFactory.GetEntityType(absTableName);

            value.ForEach(aPhysicTable =>
            {
                DbModelFactory.AddEntityType(aPhysicTable.physicTableName, ShardingHelper.MapTable(absEntityType, aPhysicTable.physicTableName));
            });
        }
Exemplo n.º 2
0
 private Type MapTable(Type absTable, string targetTableName)
 {
     return(ShardingHelper.MapTable(absTable, targetTableName));
 }