Breeze / breeze.server.net

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

update to .net standard 2.1 and updating references to latest version… #88

Closed gmareater closed 3 years ago

gmareater commented 5 years ago

Updating breeze to .net core 3.0 removed 1 bug by removing line of code my project currently works fine (Save And load) commented line below, i dont know that it does and didnt find any reference what it is even.

private static Type[] BuildGenericParameters(DynamicTypeInfo info, TypeBuilder typBuilder) {

        // generates the names T0, T1, T2 ...
        string[] parameterNames = Enumerable.Range(0, info.PropertyNames.Count).Select(i => "T" + i.ToString()).ToArray();
        var parameterBuilders = typBuilder.DefineGenericParameters(parameterNames).ToArray();
        return parameterBuilders;
        //return parameterBuilders.Select( pb => pb. .AsType()).ToArray();
    }
EchoFoxxtrot commented 4 years ago

Unfortunately, this version of Breeze.AspNetCore.NetCore is still using Microsoft.AspNetCore 2.2.0, Microsoft.AspNetCore.Mvc 2.2.0 which will conflict with ASP.NET Core 3.0.

gmareater commented 4 years ago

hi, i mean, my fork (my pull request), is an updated version of breeze which use .net core 3.0 and is working correctly on my website

ganySA commented 4 years ago

@gmareater does this work with .net core 3.0?

gmareater commented 4 years ago

yes, that's the whole point of it. I have currently production running app using breeze and .net core 3.0 my fork is simply updating all references to .net core 3.0 and commenting one buggy not important line.

ganySA commented 4 years ago

@gmareater thanks a lot for this.

Quick question do you simply import the web api 2 dll as a reference?

gmareater commented 4 years ago

actually good question, yes, after compiling used dlls

ganySA commented 4 years ago

It seems to be working ok. However in the console window i see a few errors popping up.

Connection id "0HLRLAR97JA8B", Request id "0HLRLAR97JA8B:00000001": An unhandled exception was thrown by the application.
2019-11-30T05:38:59.472950204Z System.Exception: Unable to convert this endpoint to an IQueryable
2019-11-30T05:38:59.472963404Z    at Breeze.AspNetCore.QueryFns.ExtractQueryable(ActionExecutedContext context) in C:\Users\peter\Downloads\breeze.server.net-master\AspNetCore\Breeze.AspNetCore.NetCore\QueryFns.cs:line 34
2019-11-30T05:38:59.472969704Z    at Breeze.AspNetCore.BreezeQueryFilterAttribute.OnActionExecuted(ActionExecutedContext context) in C:\Users\peter\Downloads\breeze.server.net-master\AspNetCore\Breeze.AspNetCore.NetCore\QueryFilter.cs:line 28
2019-11-30T05:38:59.473903409Z    at Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
2019-11-30T05:38:59.473916709Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2019-11-30T05:38:59.473931209Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
2019-11-30T05:38:59.473936109Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2019-11-30T05:38:59.473940709Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()

I then read the following: https://stackoverflow.com/questions/47682724/breezejs-error-unable-to-convert-this-endpoint-to-an-iqueryable

Im trying to determine if this is something with .net 3 or maybe my application, but i do not recall having this on .net 2x

ganySA commented 4 years ago

I have debugged the issue:

When my breeze query had: .orderBy('date desc').expand('client');

This is the LINQ query would fail.

    var results =  PersistenceManager.Context.Message.AsNoTracking().Where(x => roles.Contains(x.BusinessId.ToString()) && x.Direction == "IN" && x.IsRead == false && x.Date >= date).GroupBy(r => r.ClientId)
                      .Select(g => g.OrderByDescending(p => p.Date).FirstOrDefault()).Include("Client");

I remove the duplicate filter on the client, and refactored my local query and now it works.

gmareater commented 4 years ago

good job, so it's now working with .net 3.0 for you either?

ganySA commented 4 years ago

Yes it does work but there are some queries that do not work. What i can see from the current queries is that on the server at the API endpoint if one pre-filters and then on the client one also applies filters, the client side filters fail.

So you cannot have a query like in my previous comment where it has a filter using orderBy and then within the API controller method other filters. This fails.

Lucky i do not have very many of these.

I am going to test if the EntityQuery.withParameters will work as an alternative.

steveschmitt commented 3 years ago

Fixed in current (3.x and 5.x) releases of Breeze