dbelmont / ExpressionBuilder

A library that provides a simple way to create lambda expressions to filter lists and database queries.
Apache License 2.0
372 stars 105 forks source link

.Net Core 3 Issue #60

Open Dieder opened 5 years ago

Dieder commented 5 years ago

I have installed the latest NuGet package of your library with version 2.1.0-rc. Unfortunately it doesn't work at runtime. After execution, I get the following error: System.AggregateException : One or more errors occurred. (The type initializer for 'ExpressionBuilder.Helpers.OperationHelper' threw an exception.) ---- System.TypeInitializationException : The type initializer for 'ExpressionBuilder.Helpers.OperationHelper' threw an exception. -------- System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types.

The cause of the problem is found in the file ' OperationHelper.cs' operation 'LoadDefaultOperations' . I don't know why all assemblies have to be loaded with all types, but this implementation causes the error. I made a fix in the implementation of the method as follows: var @interface = typeof(IOperation); var operationsFound = typeof(IOperation).Assembly .GetTypes() .Where(p => @interface.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract) .Select(t => (IOperation)Activator.CreateInstance(t));

This will fix the issue. Furthermore the compile conditions are missing the new core 3.0 and 3.1 compiler variables.

Please, will you update the code, so it works with .Net Core 3.0? Thanks in advance.

john-roland commented 4 years ago

yes, i agree this change will be better than loading all types..

InsonusK commented 4 years ago

I have same issue, but i think project is dead. Last visit of author is more than year ago.

Dieder commented 4 years ago

Yes, its a pity. This code is very effective for filtering data with dynamic needs.

Op do 14 mei 2020 om 01:11 schreef InsonusK notifications@github.com:

I have same issue, but i think project is dead. Last visit of author is more than year ago.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dbelmont/ExpressionBuilder/issues/60#issuecomment-628292587, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA6FTVERPP4OAX63Q5AIL2DRRMSJ5ANCNFSM4JGIWYRQ .

john-roland commented 4 years ago

there is a fork here, working well on dotnet core

https://github.com/yurisouza/expressionbuildernetcore

Ive asked the author to change this dynamic conditions load, to avoid scanning all the assemblies, this is creating too much problem for little benefit.. one can use the dedicated method to add new custom conditions.

John