我有一个模型层,它由多个类组成,每个类都需要从不同的数据库中获取数据。我该如何管理它以及如何更改存储库层中的连接字符串:
public class MapRepository : EFRepository<Map>, IMapRepository
{
public MapRepository(DbContext context) : base(context) {
context.Database.Connection.ConnectionString = ""; // is this possible?!!!!
}
public IQueryable<Map> GetByMapId(Guid id)
{
return DbSet.AsQueryable().Where(bd => bd.MapId == id);
}
public IQueryable<Map> GetByMapCode(string code)
{
return DbSet
.Include("MapIndexes")
.Include("MapIndexes.MapPages")
.AsQueryable().Where(bd => bd.MapCode == code);
}
public int GetMapsCount()
{
return DbSet.Count();
}
}