Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Issue: Hard to use derived queryableattribute with global queryableattribute [542]

$
0
0
I have discussed with Youssef and RaghuRam and agree that it's an advanced scenario and we have workaround for that. The issue is raised to see if we can improve that in the future.

The problem:
MVC template will enable global query by default. So if a user decide to extend queryableattribute and apply it to one of his action which return IQ. It will fail by exception:
"ExceptionMessage":"An item with the same key has already been added.","ExceptionType":"System.ArgumentException","StackTrace":" at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)\r\n at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)\r\n at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)\r\n at System.Web.Http.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings)

The reason it fails is because it has been executed twice and write the next link to request.Properties with same key. Filter pipeline will only check the type itself to remove duplicates, and won't check its base type.

If the user decided to add his derived type to global filter, he will find that EnableQuerySupport extension methods don't accept instance of QueryableAttribute. If he puts his type to global filters instead, then everything other than IQ and IE blocks.

The workaround is to disable global queryable support and write his own filter provider to pass the derived type to filter pipeline.

The experience here is not as good as I expected. But I am fine with the workaround if there is very limited users to extend QueryableAttribute.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>