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 #27

Open ms666 opened 6 years ago

ms666 commented 6 years ago

Hey. A great job, but it does not work with a project written in the .net core. In the OperationHelper.cs file, the LoadDefaultOperations method returns an error: System.Reflection.AmbiguousMatchException: "Ambiguous match found".

I solved the problem by changing the name of the class Contains - also change all strings in this class and appropriate in the class DoesNotContain

Regards Paweł

SimonCropp commented 6 years ago

@ms666 can u try the build of this PR https://github.com/dbelmont/ExpressionBuilder/pull/30

chinnarao commented 6 years ago

can i use this Exp builder in [asp.net core 2.1 , .net core class library , ef core 2.1] , i doubt , it is tightly coupled with config file and .resx file, can you make this as nuget and utilize in any type of .net core supports projects , please dont use any config files or .resx file , if any one wants use the package then the package should support with or with out config and as well as .resx files, please think sir?

SimonCropp commented 6 years ago

@chinnarao net core does support resources. but you do raise an interesting question.

@dbelmont it seems like the resource code is only consumed by the UI and is not needed by any of the core library. is it possible to split that stuff out or remove it?

CodingGorilla commented 6 years ago

@SimonCropp Yea, I wasn't looking for an answer from you 😄 . Maybe a fork is in order?

dbelmont commented 6 years ago

Hi @ms666, @SimonCropp, @chinnarao, @CodingGorilla, Sorry for this late reply, I've been busy with other stuff (you know, life happens... 😅). It hadn't crossed my mind that the project could not work on .Net Core. I'll have a look. I should have some time to dedicate to the project soon. Cheers.

labiej commented 6 years ago

Hi @dbelmont

I ran a quick Portability analysis and the results are quite good as you can see in this attached report ApiPortAnalysis.xlsx

Only .Net Standard has some issues, all of them present in ExpressionBuilder/ExpressionBuilder/Configuration/ExpressionBuilderConfig.cs

I can look into it sometime in the coming week(s) if you like.

Joris

eveneveneven commented 5 years ago

Hi @dbelmont

I ran a quick Portability analysis and the results are quite good as you can see in this attached report ApiPortAnalysis.xlsx

Only .Net Standard has some issues, all of them present in ExpressionBuilder/ExpressionBuilder/Configuration/ExpressionBuilderConfig.cs

I can look into it sometime in the coming week(s) if you like.

Joris

Did you have a look at this @labiej ? Would be great to be able to use this with .NET Standard, and getting rid of the dependencies in ExpressionBuilderConfig seems like it would be a trivial task?

labiej commented 5 years ago

Sorry haven't had time yet, @eveneveneven . Maybe sunday otherwise it would have to wait until next weekend as I'm quite busy during the week.

Kind regards,

Joris

dbelmont commented 5 years ago

Hi @labiej,

Many thanks for offering to have a look at that. There's an increasing number of people asking to support .Net Core.

My second child was born last week so you can imagine how busy I am right now 😄, but I should have a moment to take a look at all those issues (sometime) in the next two months. But, of course, every help is welcome and very appreciated.

Please, let me know if you could do something around this. Once again, many thanks.

Best regards, David

eveneveneven commented 5 years ago

Congratulations @dbelmont! If I had more of either time or ideas of how to do it I'd be glad to help, but I'm patiently waiting for @labiej as it seems he might be able to do something when he finds the time. Thanks @labiej :)

labiej commented 5 years ago

A quick update @eveneveneven and @dbelmont

Well I've been working on this for a few hours so far.

It looks like I might be close all I need to do now is verify the generated dlls. I'm hoping I can open a pull request tonight or tomorrow.

The tests haven't been ported at the moment but they do run. I'll need to figure out how to test both versions from the same project but I suspect that might be easy.

There are two new nuget dependencies for the net standard (2.0) version. System.Configuration.ConfigurationManager (ExpressionBuilderConfig.cs) System.ComponentModel.Annotations (RangeAttribute used in IOperation f.e.)

Kind regards,

Joris

dbelmont commented 5 years ago

Hi @labiej,

Many thanks for your contribution. 😃 I merged your pull request to a new branch so that I can study a way to port the tests. Once I finish working on another couple of issues, I will create a new release containing your changes as well.

Kind regards, David

dbelmont commented 5 years ago

Hi @ms666, @labiej, @eveneveneven, @SimonCropp, @chinnarao, @CodingGorilla,

I'm pleased to announce that I've just published a pre-release package at NuGet.org with support for .Net Core. Would you mind checking that out and leaving a comment here to let me know if it's working correctly?

Kind regards, David

P.S.: BTW, I'm really sorry that I missed your pull request, @SimonCropp. Only now I realized you had proposed the solution for this issue long ago. Last year's second semester was pretty busy for me and I had to focus on other things for a while. I'll update the documentation to give you credit for this too, as the solution you proposed is pretty similar to what as implemented.

SimonCropp commented 5 years ago

@dbelmont no worries :) and no credit needed. just happy to have helped in any way

SanchitChawla21 commented 5 years ago

I got the latest, but seems like this library is not working on ASP.net core 2.1

SimonCropp commented 5 years ago

@SanchitChawla21 perhaps u can give some more detail to " is not working"?

Arthur-Z commented 5 years ago

System.TypeInitializationException: The type initializer for 'ExpressionBuilder.Helpers.OperationHelper' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.AmbiguousMatchException: Ambiguous match found. at System.RuntimeType.GetMethodImplCommon(String name, Int32 genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) at System.Type.GetMethod(String name, BindingFlags bindingAttr) at ExpressionBuilder.Operations.Contains..ctor() --- End of inner exception stack trace --- at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean skipCheckThis, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) at ExpressionBuilder.Helpers.OperationHelper.<>c.b__4_3(Type t) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Collections.Generic.HashSet1.UnionWith(IEnumerable1 other) at System.Collections.Generic.HashSet1..ctor(IEnumerable1 collection, IEqualityComparer1 comparer) at ExpressionBuilder.Helpers.OperationHelper.LoadDefaultOperations() at ExpressionBuilder.Helpers.OperationHelper..cctor() --- End of inner exception stack trace --- at ExpressionBuilder.Helpers.OperationHelper..ctor() at ExpressionBuilder.Operations.Operation..cctor()

==== .net core 2.1

dbelmont commented 5 years ago

Hi @SanchitChawla21 and @Arthur-Z,

Thanks for giving a try for the ExpressionBuilder. I'm really sorry that you guys are experiencing problems with .Net Core 2.1. I got to be honest, I only tested with 2.0.

I had a problem with my computer recently and I'm not sure when I'll be able to have a look at this. If anyone else here is willing to help (and got some time to spare), that would be highly appreciated 🙂.

Kind regards, David

SimonCropp commented 5 years ago

I can debug into it. How do i repro?

SanchitChawla21 commented 5 years ago

@SimonCropp , you have to just update target framework to 2.1,

I believe "Ambiguous match found." error is coming when we get method for contains, I just added overload the getMethod, and it fixed the issue

>>namespace ExpressionBuilder.Operations.Contains

 readonly MethodInfo stringContainsMethod = typeof(string).GetMethod("Contains", new[] { typeof(string) });
SimonCropp commented 5 years ago

@SanchitChawla21 in that case can you submit a PR