小编Abd*_*mon的帖子

OData异常已超出Top查询的限制"0"

我正在使用OData Web API for Version 4,当我尝试使用$top参数查询OData web Api时,它会返回以下异常消息.

URI中指定的查询无效.已超出Top查询的限制"0".传入请求的值为"10"

我使用Apache Ignite dotNet LINQ作为数据源而不是Entity Framework,我的OData控制器操作方法如下:

[EnableQuery]
public IQueryable<Productioncurvepnl> GetProductioncurvepnl()
{
    Console.WriteLine("Starting query to ignite");
    var q = AIgniteClient.IgniteClient.Instance.ProductionCurvePnLCache.AsCacheQueryable().Select(c => c.Value);
    return q;
}
Run Code Online (Sandbox Code Playgroud)

c# odata asp.net-web-api-odata ignite

17
推荐指数
2
解决办法
7117
查看次数

RestSharp对Enum类型的属性进行反序列化

我有一个对象

            var testTcc = new TrendingConfigurationConfigDto
            {
                TrendingConfigurationId =1,
                ConfigId = 1,
                DeviceId = 1,
                Selected = true,
                YAxisPosition = YAxisPosition.Left,
                Order = 1,
                Color = "#ffffff",
                Configuration = new BO.Shared.Dtos.List.ConfigurationListDto
                {
                    Id = 1,
                    Name = "configuration",
                    Alias = "configuationAlias",
                    EnableEdit = true,
                    IsBusinessItem = true
                },
                Device = new BO.Shared.Dtos.List.DeviceListDto
                {
                    Id = 1,
                    Name = "Device"
                }
            };
Run Code Online (Sandbox Code Playgroud)

当我将其序列化为json时

var jsonTcc = SimpleJson.SerializeObject(testTcc);
Run Code Online (Sandbox Code Playgroud)

它返回的字符串包含YAxisPosition = 1的json对象,当我尝试使用

testTcc = SimpleJson.DeserializeObject<TrendingConfigurationConfigDto>(jsonTcc);
Run Code Online (Sandbox Code Playgroud)

它给出异常System.InvalidCastException,并显示消息“指定的转换无效”。

我尝试将json字符串中的YAxisPosition值更改为字符串“ 1”或“ Left”,这总是给我相同的错误,直到我从json字符串中删除了属性YAxisPosition。

我可能缺少一些东西(枚举属性上的Attribute或类似的东西)。

请帮助我找到一种方法,以便我可以使用RestSharp对包含Enum类型属性的对象进行序列化和反序列化。

注意:我尝试使用NewtonSoft成功进行序列化和反序列化。但是我不希望Web API客户端依赖NetwonSoft,因为我已经在使用RestSharp。

c# restsharp

4
推荐指数
1
解决办法
1535
查看次数

标签 统计

c# ×2

asp.net-web-api-odata ×1

ignite ×1

odata ×1

restsharp ×1