OperationContext.Current is returning null while in my WCF service, and I don't know why. I have no idea what it does, but I saw it used in an example.
@KendallFrey - Usually Context's are injected, perhaps it isn't injected in your scope because it either doesn't usually exist there or because you inherited but didn't accept it in a constructor or parameter
yeah, you destroy the stack trace, and, in all honesty, if you know the reason, why not throw a custom exception, and then why catch it if you're just going to re-throw
Let ask this a different way. If you had a repo that needed a repo that needed a repo you would pass them all down as parameters using each repos CTOR as interfaces would you not?
then when you are using the component you can choose whether you want to use an instance you already have, or let the repo get its own instance
hang on, im looking at your code, what is actually going on with this
// In the future I will use dep injection using ninject or something...
public CustomerController(ICustomerRepository custRepo, IUserRepository userRepo)
{
this._custRepo = new CustomerRepository();
this._userRepo = new IUserRepository();
}
@Sippy but you arent supposed to expose entities directly to the consuming classes I thought . All my repos go fetch data and pass back DTOs. asp.net/web-api/overview/older-versions/…
@Sippy seems overly complex. EF6 already does so much for you it seems crazy to keep wrapping it up into more abstractions until nothings left but complex names like TryAddObject instead of userRepo.Save(new UserDTO(){ name = "John Doe"});
@Sippy im trying not to. All I wanted to know was the best way to comply with dependency injection. CustRepo NEEDS UserRepo. Does that mean that I should do IUserRepo and have CustRepo take it?
Well thats what 90% of ASP.NET the website explains to do. Especially since you can use dep injection or IoC whatever the heck people call it now days to swap out the repos on the controller with test repos or repos that use sqlite instead of ef6