-
Notifications
You must be signed in to change notification settings - Fork 244
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
Feature Proposal: nhibernate support #401
Comments
I’m currently working on a project that uses NHibernate instead of Entity Framework, and I’ve found that the built-in LINQ-to-Query capabilities integrate well with this package. I’ve developed my own Repository, SpecificationEvaluator, and FetchEvaluator, while making use of the existing Where, OrderBy, and Pagination evaluators. However, implementing NHibernate’s Criteria API has been more complex. I managed to create a proof of concept by building my own Criteria API as an adapter between the Specification pattern and the evaluators. I also extended the ISpecification interface to store and retrieve criteria using the Items object. In this proof of concept, I even got the Criteria API to work with Entity Framework by generating expression trees that could interact with IQueryable. While it’s feasible to implement the Criteria API, I’m concerned that developing a fully supported version could require a significant amount of time, especially if it needs to work with both NHibernate and Entity Framework. |
Generally, we have nothing against adding support for NHibernate. We tried to make the infrastructure as flexible as possible and I believe it's easy to add/replace evaluators. If you need anything else in that regard let us know. |
I wrote a blog post on how I extended Ardalis.Specification to support NHibernate (Linq-to-query, Criteria, QueryOver). You can find examples in this demo repository. I did some "cheating" by directly referencing the Criteria and QueryOver APIs in my custom Specification classes. Initially, I considered creating an abstraction layer above these APIs, but that would have required writing a lot of extra code! The downside of this approach is that if there’s ever a need to transition from NHibernate to Entity Framework Core, any specifications written using Criteria or QueryOver will need to be rewritten using Linq. |
Hi!
Love the specification pattern and this package and wonder if there has been any thoughts, attempts or plans of starting to support nhibernate as well?
Best regards
The text was updated successfully, but these errors were encountered: