Breeze / breeze.server.net

Breeze support for .NET servers
MIT License
76 stars 62 forks source link

Error when query with parameters (breeze.sharp call breeze.server.net - Asp.Net Core/EF Core) #74

Closed dangvothanh closed 2 years ago

dangvothanh commented 6 years ago

Hello,

I have faced a problem when using breeze.sharp and breeze.server.net - Asp.Net Core + EF Core.

Everything works well when query the full list (http://localhost:5678/breeze/share/companies). But when I add parameter (http://localhost:5678/breeze/share/companies?$filter=TagName%20eq%20%27DHL%27) I get error:

{"$id":"32","$type":"Breeze.AspNetCore.ErrorDto, Breeze.AspNetCore.NetCore","Code":0,"Message":"This EntityQuery ctor requires a valid json string. The following is not json: $filter=TagName eq 'DHL'","StackTrace":" at Breeze.Core.EntityQuery..ctor(String json) in D:\GitHub\Breeze\breeze.server.net\AspNetCore\Breeze.Core\Query\EntityQuery.cs:line 37\r\n at Breeze.AspNetCore.BreezeQueryFilterAttribute.OnActionExecuted(ActionExecutedContext context) in D:\GitHub\Breeze\breeze.server.net\AspNetCore\Breeze.AspNetCore.NetCore\QueryFilter.cs:line 33\r\n at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()","EntityErrors":null}

Try to debug deeper the source code of breeze.server.net and found the error happens in file JsonHelper.cs at line 12........... JToken.parse(json).....

Unable to create the JToken from the query string.

Please help....

marcelgood commented 6 years ago

The Asp.NET Core Breeze server doesn't support the OData query syntax, which is what the above URI with parameters is. It exclusively supports the Json query syntax. However, breeze.sharp currently has no support for the Json format, so unfortunately you won't be able to use breeze.sharp in conjunction with the .NET Core Breeze server. Only breeze.js currently has support for the Json format.

http://breeze.github.io/doc-js/query-using-json.html

ahedreville commented 5 years ago

Any updates on this? using postman with GET http://localhost:64096/breeze/Employee/Get?$top=5 Still have same problem with the sample code https://github.com/mikemichaelis/dnc I would do like to do some test with postman, but I am unable to compose a valild json to to a GET over the upper endpoint.