MongoCollection을 내 저장소 레이어에 삽입하려고합니다. 즉 무엇을해야Generic과 Mongo로 Ninject 바인딩
Func<Type, string> namingStrategy = x => x.Name;
Kernel.Bind(typeof(MongoCollection<>))
.ToMethod(
x => x.Kernel.Get<MongoDatabase>().GetCollection(x.Request.Target.Type, namingStrategy(x.Request.Target.Type)));
, 그것은에 대한 모든 MongoCollection <가> 우리 MongoDatabase 개체에서 컬렉션 개체를 얻어서 구현의 바인드됩니다. 이 "좀"작동하지만이 오류 얻을 :
Unable to cast object of type 'MongoDB.Driver.MongoCollection`1[MongoDB.Driver.MongoCollection`1[Profile]]' to type 'MongoDB.Driver.MongoCollection`1[Profile]
공지가에서 캐스팅 것 유형 더블 generic'd입니다. 예 :
MongoCollection<MongoCollection<Profile>>
필자가 작성한 코드에서 어떻게 벗어나고 있는지 확신 할 수 없습니다. 오류를 자세히 보면,의