-
Notifications
You must be signed in to change notification settings - Fork 223
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
Unable to build OdataUntypedSample when upgraded to odata v7 #50
Comments
Same thing with DynamicEdmModelCreation. |
I had the same problem. It seems the new packages contains (a lot of) breaking changes. I finally found a solution. Now that HttpRequestMessageProperties doesn't contain a Model property anymore, to get the model, you just need the new version (should come with the packages update) of HttpRequestMessageExtensions class that contains a GetModel extension method. So I replaced
by
Note I'm unable to find any reference of this change anywhere, and worst, I'm also unable to find the change in the open source available on the supposed repositories here: https://github.com/OData/WebApi/blob/master/OData/src/System.Web.Http.OData/Extensions/HttpRequestMessageExtensions.cs or anywhere else on the Internet :-( |
@smourier thanks for this. Do you know of any way to set the model in the request? |
Same question? How should we set the model now? |
@joserito - I think I ended up just using an older version of OData which isn't ideal... |
Any Update on this please? |
About the initial question, my answer is still valid, you just have to change one line (replace About the how to set the model in the request, well, you're still supposed to use routes, like what's done here in the sample:
Note since my original answer, these changes are somewhat documented here (if you want to tweak the whole system): https://odata.github.io/WebApi/13-04-DependencyInjection/ and the code in System.Web.OData dependency that wasn't available back then is now here: https://github.com/OData/WebApi/blob/master/src/System.Web.OData/Extensions/HttpRequestMessageExtensions.cs |
We are using something similar to the code used in HttpRequestMessageProperties odataProperties = request.ODataProperties(); we can't set the model dynacmically with the new version 7. Not sure how to achieve the same functionality. |
You could post your question on StackOverflow I guess. |
@rbmanian75 @smourier @jlkalberer @joserito @azachert I just added a new ODataUntypedSample project to target the Web API OData v6.0 and ODataLib v7.0. |
Thank you for the update. It would be great if you could update this sample also because with odatalib 7 it is not possible to set the model dynamically. Thank you |
Any update on this? Anyone figure out a solution for dynamic models? |
I have a same problem using DynamicEdmModelCreation for version 7.0.0. |
I have something I think would work as a solution which I was using in conjunction with the dynamic EDM models -- but I can probably replace the dynamic EDM models with this. It basically updates the Last night I was thinking of updating it a bit more (to support more than filtering on my
I'll post an update with link to the code if I get to it. Personally, I'd really like to update my OData code to v7 so this should happen soonish |
Hey everyone, I got motivated over the weekend and I implemented a different way to filter the properties on entities by overriding the behavior of the Please pull the repo and try it out. Let me know if it's missing some features and send a pull request if you can think of any improvements. |
@smourier I have the following error |
@rbmanian75 @azachert @jlkalberer @joserito |
Hi folks! :-) The new version of the OData Libraries use the default DI container to manage dependencies and services. The model ( To implement a model-per-request pattern (as in the I need the dynamic model creation (model-per-request) feature and will look into fixing the sample soon. There are some more obstacles beside the dynamic model creation. I hope to look into the rest ver soon and keep up updated. Cheers, Matt See: #65 (comment) |
Waiting to see the samples. We are stuck in upgrading our project for long time because of this issue. |
So the key is just this line I will give your code a go but I tried using dependency injection. The callback would only run once so the model wasn't being recreated... maybe my scope was just wrong or there is more to the example than I'm seeing. |
By seeing the sample i am trying to upgrade our project. We are using a custom odata query parser where we are parsing the $filter property like this ` HttpRequestMessageProperties odataProperties = this.Request.ODataProperties();
Here we are using the odata model from oDataProperties(). We are not sure how to determine the model at this place where we are using custom parser to filter the data. |
@rbmanian75 - check out my example. I actually do this there. I think the code is outdated and has a few bugs but it will give you the general idea. |
I managed to get the model from the new method Request.GetModel(). Thanks |
The sample you have provided when hosted in asp.net gives the following error.(in our project we host odata in asp.net). The error happens in the line configuration.Routes.Remove(routeName); But when self hosted it works fine. Is there anyway we can fix this? Exception Details: System.NotSupportedException: This operation is not supported by 'HostedHttpRouteCollection'. Source Error: Line 35: Source File: C:\S\SGC\Sgc.Web\OData.Web\Handlers\ODataCustom\DynamicModelHelper.cs Line: 37 ` |
To Solve the above mentioned issue there should be a way to specify the customodataroute and customodatapathrouteconstraint in mapodataserviceroute. Please check this issue also OData/WebApi#826 |
Hi everyone, In my case "$expand" is not working. Associate/Child records not returned in result. Error details: https://stackoverflow.com/questions/50265218/expand-not-working-associate-child-records-not-returned-in-result-update |
I don't understand this comment. Request.GetModel() (and SetModel) methods were made obsolete long ago and replaced with the very ODataProperties().Model gettable-settable property which is here also removed albeit without a clear replacement. There is the referred App_Start sample for providing a model on demand through the registered delegate. When we had a HttpRequestMessage it used to be possible to set the edm model for it, and I don't understand how to do the same here. My specific case is complicated by trying this in the context of a unit test for a service with dynamic EDM, upgrading the service from the older odata injection with gettable-settable property to the current approach. |
Hi,
I tried upgrading the odatauntypedsample project to odata libraries version 7 and i am getting build errors
Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'Library' does not exist in the namespace 'Microsoft.OData.Edm' (are you missing an assembly reference?) ODataUntypedSample D:\Balu\Sgc\ODatav4 Sample\ODataSamples-master\WebApi\v4\ODataUntypedSample\ODataUntypedSample\Controllers\ProductsController.cs 8 Active
Severity Code Description Project File Line Suppression State
Error CS1061 'HttpRequestMessageProperties' does not contain a definition for 'Model' and no extension method 'Model' accepting a first argument of type 'HttpRequestMessageProperties' could be found (are you missing a using directive or an assembly reference?) ODataUntypedSample D:\Balu\Sgc\ODatav4 Sample\ODataSamples-master\WebApi\v4\ODataUntypedSample\ODataUntypedSample\Controllers\ProductsController.cs 41 Active
Is there any breaking change with OData Libraries version 7.
Thanks
The text was updated successfully, but these errors were encountered: