Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

orderby, top , filters not working #57

Closed
eyadhodiani opened this issue Jun 23, 2017 · 10 comments
Closed

orderby, top , filters not working #57

eyadhodiani opened this issue Jun 23, 2017 · 10 comments

Comments

@eyadhodiani
Copy link

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
Copy link
Contributor

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
Copy link

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

go?

@nigel-dewar
Copy link

Never mind I found out where.

@nigel-dewar
Copy link

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
Copy link

wstow commented Sep 15, 2017

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

@WisdomCorp
Copy link

WisdomCorp commented Nov 10, 2017

Where we need to specify -

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

@WisdomCorp
Copy link

WisdomCorp commented Nov 10, 2017

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
Copy link

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
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants