-
Notifications
You must be signed in to change notification settings - Fork 934
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
Allow custom query loader #3209
Allow custom query loader #3209
Conversation
- IQueryLoader - ILoader - ILinqQueryExpression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests for the change should be added: check that providing a custom query loader factory works as expected, for all querying interface NHibernate has. I suspect it may break where I have asked about a possible missing type change.
Also, the possibility of supplying a custom query loader factory should likely be surfaced to the NHibernate configuration, in a similar way to what we do for most other factories (see linqtohql.generatorsregistry
, collectiontype.factory_class
, query.factory_class
, ...).
|
- QueryLoaderFactory added - IQueryTranslator only publishes the Loader property of type Loader.Loader again - Type of Loader property of ITranslator is of type Loader.Loader again - ICacheableQueryExpression is only internal again - additional constructors added to QueryTranslatorImpl, QueryInfo to ensure backwards compatibility - QueryCacheResultBuilder method restored to ensure backwards compatibility
I've added tests that should use a custom But, it seems that |
I have pushed the commit I had written about. I got by the way a better view of what was actually needed. So, about some of my previous comments:
It is indeed not needed, the current translator factory is enough.
Indeed a bit broad since that change does apply neither to Criteria nor QueryOver (nor native queries). |
I'm glad that you got a better view on it and I thankful for your commit. I'll still add the FutureQuery-Test to ensure that there it is no breaking change. |
Co-authored-by: Frédéric Delaporte <12201973+fredericDelaporte@users.noreply.github.com>
Co-authored-by: Frédéric Delaporte <12201973+fredericDelaporte@users.noreply.github.com>
- HqlTranslatorWrapper for future queries implements the ITranslatorWithCustomizableLoader now - documentation added for test classes
I think
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to adjust these additional points.
src/NHibernate.Test/QueryTranslator/CustomQueryLoaderFixture.cs
Outdated
Show resolved
Hide resolved
src/NHibernate.Test/QueryTranslator/CustomQueryLoaderFixture.cs
Outdated
Show resolved
Hide resolved
And adjust the tests.
👍 I can recommend this NuGet package for more verbose assertions FluentAssertions. |
Just for information, you can find the plugin to support MSSQL Table-Valued Functions with Linq here: |
Hello,
I'm currently working on a NHibernate-Linq plugin to support MSSQL Table-Valued-Functions, which I plan to release as open source software.
My entry points are the following ones:
<property name="query.linq_provider_class"/>
<property name="query.factory_class"/>
The plugin propagates the Table-Value parameters down to a custom query loader via the following steps
DefaultQueryProvider
implementation to override thePrepareQuery
methodNhLinqExpression
to keep track ofParameterDescriptors
ParameterValuesByName
NamedParameters
and to pass the query/parameter verification checks.
ParameterMetaData
by Table-Valued parameters via decoratedBuildParameterMetadata
method of query translatorQueryLoader
implementation to expand parameters by Table-Valued parameters via overriddenCreateSqlCommand
method. Expanding the parameters works quite similar like the session filter parameter implementation.But to get this working and not to use reflection, I need some changes to support Dependency Inversion in the following areas:
ILoader
andIQueryLoader
interfacesQueryTranslatorImpl
constructor extended by a factory method to create anIQueryLoader
on demandNhLinqExpression
implementsILinqQueryExpression
, which extendsIQueryExpression, ICacheableQueryExpression
NhLinqExpression
toILinqQueryExpression
inQueryPlanCache::PreparePlanToCache, PreparePlanToCache::CopyIfRequired
CopyExpressionTranslation
public accessible viaILinqQueryExpression
nowNhLinqExpressionCache
depends onILinqQueryExpression
now instead ofNhLinqExpression
Basically, the functionality of NHibernate has not changed at all. Some classes depend on abstractions now instead on concrete implementations.
What do you think about these changes?
BR,
Michael