我正在构建一个使用breezejs和typescript的ASP.NET Core项目。神秘之处在于,当我在没有谓词的情况下加载数据时,所有操作都正常,但是当添加谓词来过滤数据时,会出现错误:“内部服务器错误”。 。我试图在控制器中调试,当浏览器发出请求时,它可以到达控制器。
但是,在js方面,请求没有返回,这意味着js代码无法通过断点。
executeQuery(query) {
return this.manager
.executeQuery(query.using(breeze.FetchStrategy.FromServer || this.fetchStrategy))
.then(function (data) {
return data.results;//my breakpoint
});
}
控制器:
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Jumpstart.Web.Data;
using Microsoft.AspNetCore.Authorization;
using Jumpstart.Model;
using Breeze.AspNetCore;
using Newtonsoft.Json.Linq;
using Breeze.Persistence;
namespace Jumpstart.Web.Controllers
{
[Produces("application/json")]
[Route("breeze/[controller]/[action]")]
[BreezeQueryFilter]
public class JumpstartController : Controller
{
private readonly IUnitOfWork _uitOfWork;
public JumpstartController(IUnitOfWork uitOfWork)
{
_uitOfWork = uitOfWork;
}
/// <summary>
/// Get public tenants
/// </summary>
/// <returns>IQueryable tenants</returns>
[HttpGet]
[AllowAnonymous]
public IQueryable<Tenant> Tenants()
{
return _uitOfWork.TenantRepository.All();
}
请求:
Request URL:http://localhost:50481/breeze/Jumpstart/tenants?$filter=Id%20eq%20guid%2709ae9363-240a-46d7-b5a6-30529e7dee63%27&
Request Method:GET
Status Code:500 Internal Server Error
答案 0 :(得分:1)
解决方案是:
breeze.config.initializeAdapterInstance("uriBuilder", "json");