Git Product home page Git Product logo

Comments (3)

jcachat avatar jcachat commented on May 10, 2024

This is something I was thinking about recently too. And also to be able to set parameter values on a per query basis. But, I'm not sure there is a way that I can store that information attached to the query and then retrieve it again during the query parameter substitution. But I'll give it some more thought and see if I can some up with something.

In the meantime, you can disable the filter (which is scoped to just that DbContext instance) before executing the query and then re-enable it after the query. It's not as clean as the syntax you're proposing, but it will get the job done.

from entityframework.dynamicfilters.

hikalkan avatar hikalkan commented on May 10, 2024

Thanks for your answer. I want to hear if you can find a good solution.

from entityframework.dynamicfilters.

TehWardy avatar TehWardy commented on May 10, 2024

random thought @JacHat how about an extension method for an IQueryableT that takes the context in so you can do that behind the scenes, the resulting code to give you literally everything you needed might look something like ...

DbContext.Set<User>()
    .AsQueryable()
    .DisableFilter("SoftDeleteFilter", DbContext)
    .Where(u => u.DeletionTime > SOME_TIME)
    .ToList()
    .ReEnableFilters(DbContext);

its not perfect but it does allow the functionality and abstracts from the current querying code the extra calls to remove or add the filter as needed.

You may not need the ReEnable bit on the end if you "track" the next call actually executed on the context from when the disable filter extension is called somehow (but I admit I don't know enough about what you are seeing in terms of variables to hand in such a context)

from entityframework.dynamicfilters.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.