我有两个使用NLB运行的IIS服务器.不幸的是,我无法使用共享会话服务器,因此每个服务器都使用自己的会话.如何确保来自同一用户的所有请求都转发到同一IIS服务器?
假设我有IRepository接口及其实现SqlRepository,它将LINQ作为参数作为SQL DataContext的参数.假设我有IService接口及其实现服务,它需要三个IRepository,IRepository和IRepository.演示代码如下:
public interface IRepository<T> { }
public class SqlRepository<T> : IRepository<T>
{
public SqlRepository(DataContext dc) { ... }
}
public interface IService<T> { }
public class Service<T,T1,T2,T3> : IService<T>
{
public Service(IRepository<T1> r1, IRepository<T2>, IRepository<T3>) { ... }
}
Run Code Online (Sandbox Code Playgroud)
在创建Service类以使用相同的DataContext注入所有三个存储库时,是否有任何方法?