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

Support hasconversion in EF core for filter #10

Open
pdevito3 opened this issue Jul 24, 2023 · 2 comments
Open

Support hasconversion in EF core for filter #10

pdevito3 opened this issue Jul 24, 2023 · 2 comments

Comments

@pdevito3
Copy link
Owner

Problem

When you have a VO using HasConversion like below, you need to do expressions in EF like x => x.Email == "thing" instead of x => x.Email.Value == "thing" vs using OwnsOne where you would always use the full path.

        builder.Property(x => x.Email)
            .HasConversion(x => x.Value, x => new EmailAddress(x))
            .HasColumnName("email")
            .IsRequired(false);

        builder.OwnsOne(x => x.Email, opts =>
             {
                 opts.Property(x => x.Value).HasColumnName("email");
             }).Navigation(x => x.Email)
             .IsRequired();

so ideally, the parser defaults to using the whole path, but if you pass a config object, the parser respects the path you give, so this:

        var config = new QueryKitProcessorConfiguration(config =>
        {
            config.Property<TestingPerson>(x => x.Email).HasQueryName("email");
        });

would really resolve to x => x.Email == "thing"

i started looking at this and found i can tack something like this into LeftExprParser , but then the type isn't recognized in CreateRightExpr when it calls TypeConversionFunctions, but you do need to know the type to do it right (e.g. if it's a guid or whatever)

            // Check if the nested property has a child property
            if (nestedPropertyExpression is MemberExpression memberExpression &&
                memberExpression.Expression is MemberExpression parentExpression)
            {
                return parentExpression;
            }

I think to make this work, i need to add a HasConversion() extension myself that essentially mimics the EF core method?

@jovanivanovic
Copy link

Hey @pdevito3, any news on this feature?

@pdevito3
Copy link
Owner Author

Still in the backlog. Open to PRs of tie interested.

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

2 participants