odata

System.NotSupportedException when calling OData service from NetCoreApp2.1

邮差的信 提交于 2021-02-04 14:13:16
问题 I have set up a multi targetting (net4.5.2/netstandard2) class library allowing to consume one of our enterprise OData services. To access this OData service we use a proxy class generated with the OData v4 Client Code Generator (v7.5.0) Unfortunately, when trying to use my library in a Netcoreapp2.1 application I encounter an issue as soon as I try to enumerate a collection. Container.MyDataSet.ToList(); produces the following exception : "System.NotSupportedException : This target framework

How to support a nested open complex type in the OData C# driver?

こ雲淡風輕ζ 提交于 2021-02-04 14:12:07
问题 I am using the following C# OData packages, in a .NET Web Api project: Install-Package Microsoft.AspNet.OData Install-Package Microsoft.AspNet.WebApi.OData When following Microsoft's example Use Open Types in OData v4, everything seems to work as expected, as long as the open type does not contain additional nested open complex types. This means that this will work fine: public class WplController : ODataController { private List<AbstractMongoDocument> _documents = new List

How to support a nested open complex type in the OData C# driver?

 ̄綄美尐妖づ 提交于 2021-02-04 14:07:53
问题 I am using the following C# OData packages, in a .NET Web Api project: Install-Package Microsoft.AspNet.OData Install-Package Microsoft.AspNet.WebApi.OData When following Microsoft's example Use Open Types in OData v4, everything seems to work as expected, as long as the open type does not contain additional nested open complex types. This means that this will work fine: public class WplController : ODataController { private List<AbstractMongoDocument> _documents = new List

How to support a nested open complex type in the OData C# driver?

偶尔善良 提交于 2021-02-04 14:06:42
问题 I am using the following C# OData packages, in a .NET Web Api project: Install-Package Microsoft.AspNet.OData Install-Package Microsoft.AspNet.WebApi.OData When following Microsoft's example Use Open Types in OData v4, everything seems to work as expected, as long as the open type does not contain additional nested open complex types. This means that this will work fine: public class WplController : ODataController { private List<AbstractMongoDocument> _documents = new List

OData v4 groupby with $count

和自甴很熟 提交于 2021-02-03 09:28:05
问题 I'm using OData v4 with WebAPI with these nuget-packages: Microsoft.Data.OData 5.7.0 Microsoft.AspNet.WebApi.OData 4.0.30506 I can't get groupby to work with count. It should be the most simple thing. I have a simple table/entity called Delivery . It has a status column (among several other ones). What I basically want to do is this SQL query, but with OData: SELECT e.status, count(*) AS total FROM Delivery e GROUP BY e.status I've tried using countdistinct, but it doesn't give me the correct

OData v4 groupby with $count

杀马特。学长 韩版系。学妹 提交于 2021-02-03 09:25:59
问题 I'm using OData v4 with WebAPI with these nuget-packages: Microsoft.Data.OData 5.7.0 Microsoft.AspNet.WebApi.OData 4.0.30506 I can't get groupby to work with count. It should be the most simple thing. I have a simple table/entity called Delivery . It has a status column (among several other ones). What I basically want to do is this SQL query, but with OData: SELECT e.status, count(*) AS total FROM Delivery e GROUP BY e.status I've tried using countdistinct, but it doesn't give me the correct

Calculated Properties in Odata v4 and Entity Framework

末鹿安然 提交于 2021-01-29 04:24:34
问题 Im working on a .Net Web Api 2.2 project and I'm using Odata v4 and Entity Framework code first. I need to have a calculated property in a Model which is not to be saved in Database. I have tried [notmapped] attribute. But it hides the property in Odata $medadata. How can I overcome this issue? 回答1: You can manually add this property into model. You can refer to the sample codes in: How to get Web API OData v4 to use DateTime Hope it can help. 来源: https://stackoverflow.com/questions/31191013

OData Property count of entire collection

旧城冷巷雨未停 提交于 2021-01-29 02:27:56
问题 I have an asp.net core 3.2 api which uses ef core and OData to return data to the client. I need to be able return the count of an expanded one-to-one property in a list of objects along with the parent object list. Since I am paging the results, the @odata.count represents the count of records in the database that match the criteria, not the count of records it actually returns. To explain lets say we have a couple of classes public class Order { public int Id { get; set; } public string

How to register an OData Serializer Provider with AspNet.OData v6

删除回忆录丶 提交于 2021-01-28 11:32:51
问题 Microsoft.AspNet.Odata changed the way you register services like serializers. What should the new format look like? 回答1: Your new config should look something like this. You need to add at least the first 2 services (IEdmModel and IEnumerable IODataRoutingConvention), and then you can add your own. For example, a custom odata serializer provider. using Boomerang.OData; using Boomerang.Models; using Microsoft.OData; using Microsoft.OData.Edm; using System; using System.Collections.Generic;

Odata Deserialize in json with Enum DisplayName or EnumMember Value

馋奶兔 提交于 2021-01-28 09:07:44
问题 I have an enum declared in c#. Having Display Name/ EnumMember value annotation and Student Class. I'm using asp.net core 2.2+ version with Odata. [DataContract] Public Class Library { public int Id {get;set;} [DataMember(Name="Book_Name")] public BookNameEnum BookName {get; set;} } [DataContract] JsonConverter[typeof(StringEnumConverter)] public enum BookNameEnum { [Display(Name ="John Wick"), EnumMember(value="John Wick")] JohnWick = 1, [Display(Name ="John Snow"), EnumMember(value="John