Skip to content

Allow to use dynamic objects as dynamic components #1778

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

Merged
merged 2 commits into from
Oct 30, 2018

Conversation

hazzik
Copy link
Member

@hazzik hazzik commented Jun 28, 2018

Sorry for the tautology

@hazzik hazzik force-pushed the dynamic-component branch from f650789 to 34c0693 Compare June 28, 2018 03:37
@hazzik hazzik changed the title Allow dynamic in dynamic component Allow to use dynamic objects as dynamic components Jun 28, 2018
@hazzik hazzik added this to the 5.2 milestone Jun 28, 2018
@hazzik hazzik force-pushed the dynamic-component branch 3 times, most recently from d2ad250 to 5f1bf8d Compare June 28, 2018 05:23
@fredericDelaporte

This comment has been minimized.

@fredericDelaporte

This comment has been minimized.

@fredericDelaporte
Copy link
Member

Commit added for updating the documentation.

@hazzik

This comment has been minimized.

@fredericDelaporte

This comment has been minimized.

@@ -48,7 +48,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.8" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.8.11" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 1.0.8 version did not work on mono/.NET Core due to this bug: zzzprojects/System.Linq.Dynamic.Core#157. So updated to latest.

@hazzik

This comment has been minimized.

@fredericDelaporte

This comment has been minimized.

@hazzik

This comment has been minimized.

@hazzik

This comment has been minimized.

@@ -206,6 +222,18 @@ private HqlTreeNode VisitNhNominated(NhNominatedExpression nhNominatedExpression

private HqlTreeNode VisitInvocationExpression(InvocationExpression expression)
{
//This is an ugly workaround for dynamic expressions.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In .NET Core/Mono the DynamicExpression is "reduced" to a CallSite delegate call, but on full .NET it does not happen.

@hazzik
Copy link
Member Author

hazzik commented Jun 29, 2018

Regardless of the views on relations with dynamic-entity vs dynamic-component can we agree to move with the different PRs for them?

@nhibernate nhibernate deleted a comment from fredericDelaporte Jun 29, 2018
Copy link
Member

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squashed.

@hazzik
Copy link
Member Author

hazzik commented Jun 30, 2018

I wonder. The System.Linq.Dynamic.Core supports only GetMemberBinder. Do we need to care about other binder types?

@fredericDelaporte
Copy link
Member

I am not knowledgeable enough in that area for telling. Would it allow to better support querying a component sub-collection? (I mean, if a dynamic component owns a collection, currently trying to apply to it an .Any condition will fail, the dynamic expression engine being not able to recognize it as a collection.)

@hazzik
Copy link
Member Author

hazzik commented Jul 3, 2018

Would it allow to better support querying a component sub-collection?

Unlikely

if a dynamic component owns a collection, currently trying to apply to it an .Any condition will fail, the dynamic expression engine being not able to recognize it as a collection.

Any is an extension method. Dynamic objects do not support extension methods OOB. And System.Linq.Dynamic does not have a logic to handle such a situation.

However, this would probably work now:

customers.Where("Enumerable.Any(Phones, p=>p.Number = @0)", "1234");

@fredericDelaporte
Copy link
Member

fredericDelaporte commented Jul 3, 2018

I wonder. The System.Linq.Dynamic.Core supports only GetMemberBinder. Do we need to care about other binder types?

I have taken a look at it. The other types are GetIndexBinder, SetMemberBinder and SetIndexBinder, right?

Supporting GetIndexBinder should allow to support dictionary syntax in dynamic Linq. Why not but I do not see much value in it. The dictionary syntax is quite ugly. Maybe we should even obsolete it, now that dynamic is supported.

About the setters, maybe it could make sense to support them for NHibernate linq update and insert extensions. But since they already supports anonymous objects, I do not think we really need to do that.

Update: and there are also DeleteMemberBinder, DeleteIndexBinder and InvokeMemberBinder. The two formers, I do not see in which case supporting them could be useful. The later could maybe allow to support the Any case.

@hazzik
Copy link
Member Author

hazzik commented Jul 3, 2018

I have taken a look at it. The other types are GetIndexBinder, SetMemberBinder and SetIndexBinder, right?

Yes, these are the ones which potentially interest us. Others are not so interested.

The later could maybe allow to support the Any case.

Again, this is not supported by the "dynamic" provider.

Also, I could not find any provider which does support/use System.Linq.Expressions.DynamicExpression "in the wild" (except the System.Linq.Dynamic.Core which has very limited use of it and only emits GetMemberBinder).

We could write tests which construct the desired expressions and add support for them, but do we want to do this?

@fredericDelaporte
Copy link
Member

Without concrete use cases, no.

@hazzik
Copy link
Member Author

hazzik commented Jul 4, 2018

Just force-pushed to be inline with the master. No changes.

@hazzik
Copy link
Member Author

hazzik commented Jul 19, 2018

Related #947

@fredericDelaporte
Copy link
Member

Any reason for not merging this?

@hazzik
Copy link
Member Author

hazzik commented Sep 16, 2018

I wanted to keep these as 2 commits, which will require to rebase on master once again. But I never got time to finish.

@fredericDelaporte
Copy link
Member

I have locally checked the rebase, no trouble, no conflict to resolve. It also seems the two commits of this PR could be directly merged (with merge commit) without a rebase. Maybe were you thinking about #1452, on which I have the same question, and that I consider merging very soon.

Copy link
Member

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased.

@hazzik
Copy link
Member Author

hazzik commented Oct 30, 2018

Rebased with fix.

@hazzik
Copy link
Member Author

hazzik commented Oct 30, 2018

I intend to merge it as soon as test pass, please do not merge anything to master before this PR is merged.

@fredericDelaporte

This comment has been minimized.

@fredericDelaporte

This comment has been minimized.

@hazzik hazzik deleted the dynamic-component branch March 15, 2019 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants