odata-v4

ASP.NET allow anonymous access to OData $metadata when site has global AuthorizeAttribute

眉间皱痕 提交于 2019-12-11 10:05:47
问题 I have an ASP.NET OData site that has the following in the WebApiConfig file: config.Filters.Add(new AuthorizeAttribute()) This forces all callers to authenticate before calling any of the controllers. Unfortunately, this also forces user authentication to access the "$metadata" url. I need to globally force authentication for all controller access while also allowing anonymous access the the "$metadata" url. 回答1: Create a custom filter that derives from AuthorizeAttribute and override the

Perform OrderBy on the results of Apply with Aggregate OData Version 4

我只是一个虾纸丫 提交于 2019-12-11 08:05:57
问题 Consider I have an odata query like this: Sessions?$apply=filter(SomeColumn eq 1)/groupby((Application/Name), aggregate(TotalLaunchesCount with sum as Total)) Sessions and Application entities are linked by ApplicationId. I want to apply orderby on "Total" and get top 5 results as odata query response. I tried adding &$top=5 at the end of the above mentioned query. Its says: The query specified in the URI is not valid. Could not find a property named 'Total' on type 'Sessions'. Can anyone

How to add complex properties on a model built with ODataConventionModelBuilder from an EF model

帅比萌擦擦* 提交于 2019-12-11 06:57:41
问题 I have a model that is defined in EF database first edmx. From there I expose some tables and views (mainly views). As it's possible to augment the EF model with OData, how could I add a navigation property of a complex type to another EF and OData exposed type? Currently I define a partial class and add the properties and attributes using them. But it looks like it's possible to add the desired properties with OData's modelbuilder functionality too, or perhaps better yet, first use

Tool to visualise OData WebAPI / WCF Data Service?

£可爱£侵袭症+ 提交于 2019-12-08 06:42:18
问题 This question is about situation when you get access to the DataService and want to quickly explore what kind of functionality (EDM?) is available. Do we have any such tool that could help us to learn services? Something like building class diagram from the code during re-engineering... 回答1: LINQPad implements an "OData / WCF Data Services" connector. So, you can explore metadata and query data quikly. 回答2: I had the same issue that I wanted our customers to have a visualization of our OData

Tool to visualise OData WebAPI / WCF Data Service?

二次信任 提交于 2019-12-06 16:42:30
This question is about situation when you get access to the DataService and want to quickly explore what kind of functionality (EDM?) is available. Do we have any such tool that could help us to learn services? Something like building class diagram from the code during re-engineering... LINQPad implements an "OData / WCF Data Services" connector. So, you can explore metadata and query data quikly. I had the same issue that I wanted our customers to have a visualization of our OData service. There are paid/online variants like http://www.pragmatiqa.com/product_xodata.html but in our case our

OData v4 Function always returns 404

时光毁灭记忆、已成空白 提交于 2019-12-05 06:59:32
Trying to move from OData v3 to OData v4 . Why do I keep getting a 404 when trying to use OData Functions ? Web API Config: ODataModelBuilder builder = new ODataConventionModelBuilder(); //etc builder.EntitySet<LocalizableString>("LocalizableStringApi"); //etc var getComparitiveTableFunction = builder.EntityType<LocalizableString>().Collection.Function("GetComparitiveTable"); getComparitiveTableFunction.Parameter<string>("cultureCode"); getComparitiveTableFunction.ReturnsCollection<ComparitiveLocalizableString>(); //etc config.MapODataServiceRoute("OData_Kore_CMS", "odata/kore/cms", builder

How to register OData with ASP.NET 5

心已入冬 提交于 2019-12-04 02:29:24
I have an ASP.NET 5 application and I would like to use OData v4 with it. Here is what I have tried: 1.I imported the following nuget packages: "Microsoft.AspNet.WebApi": "5.2.3", "Microsoft.AspNet.OData": "5.7.0", "Microsoft.AspNet.Hosting": "1.0.0-rc1-final" 2.Called this in the Startup.Configure method GlobalConfiguration.Configure(ConfigOData); 3.And finally this is the OData configuration private static void ConfigOData(HttpConfiguration config) { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); var EDM = builder.GetEdmModel(); //OData v4.0 config

Applying Distinct to OData query

爷,独闯天下 提交于 2019-12-03 07:50:33
I want to get a list of distinct values from my OData endpoint. But distinct or group by isn't supported yet. My URI query looks something like this GET /odata/Products?$select=foo & $top=10 & $count=true & distinct=true My Controller [EnableQuery] public IQueryable<FooBarBaz> Get(ODataQueryOptions<FooBarBaz> queryOptions, bool distinct) { //I've tried the following return Repository.AsQueryable().Distinct(); // and return Repository.AsQueryable().GroupBy(x => x.Foo); // and IQueryable query = queryOptions.ApplyTo(Repository.AsQueryable()); return query.Distinct(); // Can't call .Distinct()

GROUP BY / Case Insensitivity extension for Asp.Net Web API ODATA?

*爱你&永不变心* 提交于 2019-12-01 18:12:46
Couldn't find group by references in ODATA V4 documentation. When we pass group by query in URL it just returns the key, not the actual grouped results. Any references for using Group by in Asp.Net ODATA, on extensibility points of ODATA Web API. We're in need to take full command over how ODATA query is parsed & transformed into LILNQ to entities query. I am talking on the line of intercepting ODATA queries and performing manual customisation e.g. LINQ to Entities I am trying to achieve similar extension for Case Sensitivity. OData Case In-Sensitive filtering in Web API? 来源: https:/

GROUP BY / Case Insensitivity extension for Asp.Net Web API ODATA?

元气小坏坏 提交于 2019-12-01 17:37:20
问题 Couldn't find group by references in ODATA V4 documentation. When we pass group by query in URL it just returns the key, not the actual grouped results. Any references for using Group by in Asp.Net ODATA, on extensibility points of ODATA Web API. We're in need to take full command over how ODATA query is parsed & transformed into LILNQ to entities query. I am talking on the line of intercepting ODATA queries and performing manual customisation e.g. LINQ to Entities I am trying to achieve