-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ITimedETagQueryProvider using Ninject #253
Comments
Well, implementing should not be any different. As for registering all IoC libraries have similar concepts, so for example in my samples, instead of: Component.For<ITimedETagQueryProvider>().ImplementedBy<TimedETagQueryCarRepository>()
.LifestyleSingleton().IsDefault() I guess it just becomes: Component.Bind<ITimedETagQueryProvider>().To<TimedETagQueryCarRepository>() No? |
Thank you for your response. I tried that but it doesn't call the QueryAsync method. I get the following error in postman when I pass the If-None-Match. {
"Message": "An error has occurred.",
"ExceptionMessage": "An item with the same key has already been added.",
"ExceptionType": "System.ArgumentException",
"StackTrace": " at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at CacheCow.Server.WebApi.HttpCacheAttribute.<OnActionExecutingAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
} I created a simple solution as an example here |
Sorry but there is so much not right in there, never used Ninject but I guess that HTTP module is doing something nasty. I can see the code is called twice, it does not resolve the dependencies, etc. Bear in mind, you would normally want to include |
I agree with you the issue is related to Ninject but the interesting thing is The Ninject resolve other dependencies, I tested the solution with Castle again. It works fine. |
Another question. In your provided sample (CacheCow.Samples.WebApi.WithQueryAndIoc) if you create a new car with (C) and then use (L) to get the last item, my expectation is that the second time that we use (L) we should get the result from the cache and the method "cars/get/{id}" shouldn't be called. Is that right? Thank you in advance |
Yes you are right, it is broken in Web API, it is working in MVC. Not sure how since it should have been covered by so many tests. Thanks for the tip, let me find out. |
OK problem was that for If you are supplying your QueryProvider, make sure the registration is done for both. Note how this works: unless it can resolve both, most likely you will get the default ones. In a real project with so many object types to return, you probably will register each separately and designate the type in attribute to guide IoC to resolve it correctly. https://github.com/aliostad/CacheCow/blob/master/src/CacheCow.Server.WebApi/CachingRuntime.cs#L43 |
Thank you, it works now |
Hi, |
No as I explained in order for a successful resolution, both |
Thank you for your response I tried your suggestion but still get the same result. I don't know what I'm missing.
CarContoller.cs
TimedETagQueryCarRepository.cs
|
Hi @aliostad |
Apologies for late reply. This is a bug! |
OK version 2.7.3 should have fixed it. |
No worries, |
Same problem?? Sorry I did not get, do you still have the same issue? |
Yes, I have exact same issue |
OK, lemme try it |
OK, when I was fixing it last time I registered the generic DefaultCacheDirectiveProvider in the sample project hence it worked. I just had to add it to default registrations. v2.7.4 should fix it. Please check it our once you can. |
Thank you for the fix! I will check it out and get back in a couple of days. |
It works fine now! |
Awesome! Apologies for it to take two fixes and so long. |
Hello,
I'm trying to implement ITimedETagQueryProvider using Ninject in ASP.NET Web API, but I couldn't find any example. Would you please provide an example.
Thank you
The text was updated successfully, but these errors were encountered: