odata skip 和 top issue
odata skip and top issue
我已经根据文档实施了 Abp.OData。
例如
http://localhost:21021/odata/regions?$count=true
可以正常工作。它returns;
{"result":[{"id":1,"name":"Gebze"},{"id":2,"name":"Ankara"},{"id":3,"name":"Bursa"}],"targetUrl":null,"success":true,"error":null,"unAuthorizedRequest":false,"__abp":true}
但是 http://localhost:21021/odata/regions?$count=true&$skip=0&$top=12 不起作用。
它returns;
{"result":null,"targetUrl":null,"success":false,"error":{"code":0,"message":"Sayfa işlenirken sunucu tarafında beklenmedik bir hata oluştu!","details":null,"validationErrors":null},"unAuthorizedRequest":false,"__abp":true}
我的启动文件是:
我的 oData 控制器是:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Abp.AspNetCore.OData.Controllers;
using Abp.Dependency;
using Abp.Domain.Repositories;
using Microsoft.AspNet.OData;
using TSE.Merkez.KalIsteks;
namespace TSE.Merkez.Web.Host.Controllers
{
[EnableQuery]
public class RegionsController : AbpODataEntityController<Region.Region>, ITransientDependency
{
public RegionsController(IRepository<Region.Region> repository) : base(repository)
{
}
//[EnableQuery]
//public override IQueryable<Region.Region> Get()
//{
// return base.Get();
//}
}
}
我收到如下错误消息
ERROR 2019-02-25 12:10:21,218 [10 ]
Mvc.ExceptionHandling.AbpExceptionFilter - Did not call Complete
method of a unit of work. Abp.AbpException: Did not call Complete
method of a unit of work. at
Abp.Domain.Uow.InnerUnitOfWorkCompleteHandle.Dispose() at
Abp.AspNetCore.Mvc.Uow.AbpUowActionFilter.d__4.MoveNext() --- End of
stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext
context) at
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State&
next, Scope& scope, Object& state, Boolean& isCompleted) at
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
你有什么想法吗?我哪里出错了?提前致谢..
好的。问题解决了。这是因为没有以正确的方式构建实体。我强迫 abp 使用来自我的旧 table 的额外 ID 属性 构建实体。但是实体中的 Id 列是为 ABP 框架保留的。我不应该强迫框架使用我的旧 Id 属性。我已将旧的 Id 数据转移到实体中的另一列,问题已解决。问候。
我已经根据文档实施了 Abp.OData。 例如
http://localhost:21021/odata/regions?$count=true
可以正常工作。它returns;
{"result":[{"id":1,"name":"Gebze"},{"id":2,"name":"Ankara"},{"id":3,"name":"Bursa"}],"targetUrl":null,"success":true,"error":null,"unAuthorizedRequest":false,"__abp":true}
但是 http://localhost:21021/odata/regions?$count=true&$skip=0&$top=12 不起作用。
它returns;
{"result":null,"targetUrl":null,"success":false,"error":{"code":0,"message":"Sayfa işlenirken sunucu tarafında beklenmedik bir hata oluştu!","details":null,"validationErrors":null},"unAuthorizedRequest":false,"__abp":true}
我的启动文件是:
我的 oData 控制器是:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Abp.AspNetCore.OData.Controllers;
using Abp.Dependency;
using Abp.Domain.Repositories;
using Microsoft.AspNet.OData;
using TSE.Merkez.KalIsteks;
namespace TSE.Merkez.Web.Host.Controllers
{
[EnableQuery]
public class RegionsController : AbpODataEntityController<Region.Region>, ITransientDependency
{
public RegionsController(IRepository<Region.Region> repository) : base(repository)
{
}
//[EnableQuery]
//public override IQueryable<Region.Region> Get()
//{
// return base.Get();
//}
}
}
我收到如下错误消息
ERROR 2019-02-25 12:10:21,218 [10 ] Mvc.ExceptionHandling.AbpExceptionFilter - Did not call Complete method of a unit of work. Abp.AbpException: Did not call Complete method of a unit of work. at Abp.Domain.Uow.InnerUnitOfWorkCompleteHandle.Dispose() at Abp.AspNetCore.Mvc.Uow.AbpUowActionFilter.d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__13.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
你有什么想法吗?我哪里出错了?提前致谢..
好的。问题解决了。这是因为没有以正确的方式构建实体。我强迫 abp 使用来自我的旧 table 的额外 ID 属性 构建实体。但是实体中的 Id 列是为 ABP 框架保留的。我不应该强迫框架使用我的旧 Id 属性。我已将旧的 Id 数据转移到实体中的另一列,问题已解决。问候。