Breeze / breeze.server.net

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

orderby, top , filters not working #57

Closed eyadhodiani closed 2 years ago

eyadhodiani commented 7 years ago

I'm trying to use Breeze with ASP.NET Core and Full Entity Framework

My issue is when I call this api: http://localhost:50969/breeze/Students?$orderby=Id&$top=3&$inlinecount=allpages

this message return to me: "This EntityQuery ctor requires a valid json string. The following is not json: $orderby=Id" { $id: "2", $type: "Breeze.AspNetCore.ErrorDto, Breeze.AspNetCore.NetFramework", Code: 0, Message: "This EntityQuery ctor requires a valid json string. The following is not json: $orderby=Id", StackTrace: " at Breeze.Core.EntityQuery..ctor(String json) at Breeze.AspNetCore.BreezeQueryFilterAttribute.OnActionExecuted(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.<OnActionExecutionAsync>d__6.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 Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__25.MoveNext() --- End of stack trace from previous location where exception was thrown --- 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.<InvokeNextExceptionFilterAsync>d__24.MoveNext()", EntityErrors: null } but when I call the same api without parameters its works fine and returns json like this: [ { $id: "3", $type: "funny2.Data.Models.Student, funny2.Data", ID: 1, LastName: "Ali", FirstMidName: "Sami", EnrollmentDate: "2017-06-23T23:28:52.873", Enrollments: null } ]

Is there any sample working fine on ASP.NET Core

marcelgood commented 7 years ago

An example is still forthcoming, but your issue is related to using the wrong uriBuilder. You need to use the json uriBuilder.

breeze.core.config.initializeAdapterInstance("uriBuilder", "json");

nigel-dewar commented 7 years ago

Where abouts does this breeze.core.config.initializeAdapterInstance("uriBuilder", "json");

go?

nigel-dewar commented 7 years ago

Never mind I found out where.

nigel-dewar commented 7 years ago

Is there going to be any update that allows one to do the queries in directly as Odata style queries either through browser, postman or fiddler?

I find being able to do this handy

Cheers

wstow commented 7 years ago

I think I need this too, where did you end up putting that code?

WisdomCorp commented 6 years ago

Where we need to specify -

breeze.core.config.initializeAdapterInstance("uriBuilder", "json");

WisdomCorp commented 6 years ago

Guys, Below is the solution I found -

First of all I think the below API is changed From:

breeze.core.config.initializeAdapterInstance("uriBuilder", "json");

even though documentation mentions above code Breeze Doc Ref

To

breeze.config.initializeAdapterInstance("uriBuilder", "json");

The above code I utilizeds as below :

breeze.config.initializeAdapterInstance("uriBuilder", "json");
var query = new breeze.EntityQuery().from('order').orderBy{'orderId');

Though my query worked I don't know for sure as the question remains

  1. Is the api changed?
  2. My other project works without adding above initialize line.
  3. And also I don't wont to put that line before every EntityQuery, how can we do it once in some config, if possible.

My project is in .Net Core and created using step mentioned here: Project ref

Any expert from BreezeJs team can shed light on this will be very helpful.

dangvothanh commented 6 years ago

Hello there,

I have faced the same problem when using breeze.sharp and breeze.server.net Asp.Net Core with EF Core.

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).....

Please help....

Thanks

WisdomCorp commented 5 years ago

Guys, Below is the solution I found -

First of all I think the below API is changed From:

breeze.core.config.initializeAdapterInstance("uriBuilder", "json");

even though documentation mentions above code Breeze Doc Ref

To

breeze.config.initializeAdapterInstance("uriBuilder", "json");

The above code I utilizeds as below :

breeze.config.initializeAdapterInstance("uriBuilder", "json");
var query = new breeze.EntityQuery().from('order').orderBy{'orderId');

Though my query worked I don't know for sure as the question remains

  1. Is the api changed?
  2. My other project works without adding above initialize line.
  3. And also I don't wont to put that line before every EntityQuery, how can we do it once in some config, if possible.

My project is in .Net Core and created using step mentioned here: Project ref

Any expert from BreezeJs team can shed light on this will be very helpful.

One Year Anniversary of the question above.

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