odata-v4

How does one define an (optional) navigation property (?$expand=) in code?

会有一股神秘感。 提交于 2020-01-05 10:29:28
问题 First the explanation and the gist, then the question. So: Let's say I have a view AccountView defined in EF (6.1.1) database first (edmx) so that the code-generated class is //This class is generated from a view by EF (edmx)... public partial class AccountView { public System.Guid Id { get; set; } public int CompanyId { get; set; } } Then I create a partial class in the same namespace ( Entities ) as [MetadataType(typeof(AccounViewMetaData))] public partial class AccounView { //This is added

In OData, is there a way to order by the first element in an array?

假装没事ソ 提交于 2020-01-02 05:44:08
问题 I have an OData 4 endpoint I call for displaying data in a table. One of the columns has a set of data concatenated from a string array within my element. Is there a way to order by the first element in the array? My element could look like this: [ { "FirstName": "John", "MiddleNames": [ "Harry", "Bobby", "Sue" ], "LastName": "Jones" }, ... more elements ] and I would like to order by MiddleNames[0]. Thanks for the help! The documentation on $orderby is sparse at best... 回答1: This is NOT

OData v4 Function always returns 404

心不动则不痛 提交于 2020-01-02 03:37:10
问题 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

How to register OData with ASP.NET 5

只谈情不闲聊 提交于 2020-01-01 08:44:09
问题 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 =

OData V4 client adding child entity

Deadly 提交于 2019-12-25 08:49:22
问题 I have a parent (Order) and child (OrderDetail) where Order already exists in the database and OrderDetail also exists in the database. All I really want to do is add another OrderDetail record bound to the Order. I have been down several paths and I'm not even sure what is the correct path. Let's make some assumptions that navigations between these are already working. I can $expand=OrderDetails fine and I can also Orders(1)/OrderDetails fine and do the reverse from OrderDetails. Based on

EF OData MySql Unknown column 'Project3.x' in 'where clause'

南楼画角 提交于 2019-12-23 02:37:06
问题 I'm using OData V4, EF6 and MySql 5.6/5.7 With below models and tables. I get the result of the Application resource fine with this call odata/Applications but I get this error when I expand on roles, as follows odata/Applications?$expand=roles. Error: An error occurred while executing the command definition. See the inner exception for details. Unknown column 'Project3.ApplicationId' in 'where clause' I know it's something with mapping, but I can't see what. public class Role { public int Id

Get the OData catalog for Web API OData v4 in XML

。_饼干妹妹 提交于 2019-12-21 04:51:42
问题 I am trying to get a Web API OData V4 endpoint up and running. I got it going finally (after removing all the DateTime properties from my endpoint) and now the listing of the entities is in JSON. I love JSON, but I use LinqPad to test my endpoints. It does not understand the JSON for the listing of the entities that are in my feed. I have looked and can't seem to find a way to change this back to XML, so I am asking here. Is there a way to have the listing of entities for a Web API OData v4

How to get Web API OData v4 to use DateTime

与世无争的帅哥 提交于 2019-12-17 15:29:01
问题 I have a fairly large data model that I want to expose using Web API OData using the OData V4 protocol. The underlying data is stored in a SQL Server 2012 database. That database has many DateTime columns in it. As I was wiring it up I got an error that System.DateTime is not supported. So here is my question, what can I do to get my DateTime columns to be seen in the OData feed? NOTE: I am not able to go back and change all my columns to DateTimeOffset columns. I tried changing the type of

odata v4 Product({key})/GenerateVariants route misconfiguration

℡╲_俬逩灬. 提交于 2019-12-13 04:44:14
问题 There is a function on product that generates the variants as a list. Currently it returns: The related entity set could not be found from the OData path This is my WebApiConfig: builder.EntityType<Product>().Function("GenerateVariants").Returns<List<ProductVariant>>(); ////.Parameter<string>("save").OptionalParameter = true; This is my method on the ProductController //http://localhost:26696/odata/Products(b2a35842-7b68-e511-beda-6c71d92133bc)/GenerateVariants [HttpGet] [ODataRoute("Products

OData query option $count in $expand not working

旧城冷巷雨未停 提交于 2019-12-12 01:55:23
问题 I tried to use $count in an $expand like this query .../OData/Foo(1)?$expand=Bars($count=true) However count is no where to be found in the result. { "...": "...", "Bars": { "...": "..." } } No error either. I'm using ASP.NET Web API OData 5.4, which is using OData v4. What gives? Not implemented yet? 回答1: This feature hasn't been implemented yet. A related issue has been created https://github.com/OData/WebApi/issues/165 . 来源: https://stackoverflow.com/questions/28967908/odata-query-option