实体框架:由多个数据库构建的单一模型

时间:2017-02-05 08:59:37

标签: c# entity-framework

我有一个模型层,它由多个类组成,每个类都需要从不同的数据库中获取数据。我该如何管理它以及如何更改存储库层中的连接字符串:

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();
        }


    }

0 个答案:

没有答案
相关问题