|
From: Richard B. (JIRA) <nh...@gm...> - 2011-05-01 10:43:47
|
Add common dialect functions as extension methods for QueryOver
---------------------------------------------------------------
Key: NH-2683
URL: http://216.121.112.228/browse/NH-2683
Project: NHibernate
Issue Type: Improvement
Components: QueryOver
Affects Versions: 3.2.0Alpha2
Reporter: Richard Brown
Assignee: Richard Brown
Priority: Minor
Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
Extensions methods can be added for these to allow queries along the lines of:
s.QueryOver<Person>()
.Where(p => p.BirthDate.Year() == 1970)
.List()
... which can be translated to:
.Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
... and in turn to:
datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Richard B. (JIRA) <nh...@gm...> - 2011-05-01 10:45:50
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20986#action_20986 ]
Richard Brown commented on NH-2683:
-----------------------------------
In addition, the documentation can be extended to include examples using the extension methods (both the new ones, and existing ones).
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-01 11:06:51
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20987#action_20987 ]
Fabio Maulo commented on NH-2683:
---------------------------------
In the base Dialect you can find all common HQL-functions registered for all dialects.
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Vahid N. (JIRA) <nh...@gm...> - 2011-05-16 16:47:45
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vahid Nasiri updated NH-2683:
-----------------------------
Attachment: QueryOverSqlFuncsExts.zip
Hi,
Regarding NH-2683, I've created an extension method (attached) which accepts a fluent based "SqlFunction().Restriction()" form methods as its argument. Please let me know what do you think about it.
BR
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
> Attachments: QueryOverSqlFuncsExts.zip
>
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Richard B. (JIRA) <nh...@gm...> - 2011-05-17 10:57:54
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21099#action_21099 ]
Richard Brown commented on NH-2683:
-----------------------------------
Hi Vahid,
I've already started down the road of implementing custom extensions (there's only 1 just now, the rest will follow). You can see an example of its usage at the bottom of the code here: http://nhibernate.svn.sourceforge.net/viewvc/nhibernate/trunk/nhibernate/src/NHibernate.Test/Criteria/Lambda/RestrictionsFixture.cs?revision=5829&view=markup
Hopefully you'll agree it's a nice syntax.
For reference, patches should include NH test cases that are self-contained (yours appear to require some kind of data setup?). In addition, the QueryOver tests mostly use unit-tests that compare the output to ICriteria (rather than slower integration tests) - and only use integration tests where necessary.
Cheers,
Richard
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
> Attachments: QueryOverSqlFuncsExts.zip
>
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Vahid N. (JIRA) <nh...@gm...> - 2011-05-17 13:05:51
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21101#action_21101 ]
Vahid Nasiri commented on NH-2683:
----------------------------------
Hi Richard,
Yes, this new syntax is much better, because in my not very recent sources of NH, I hadn't "Expression<Func<T>>" in RegisterCustomProjection. It was just "bool" not "T"! So I had to invent that fluent syntax to return just bool. I'll rewrite everything!
Thanks for the comments.
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
> Attachments: QueryOverSqlFuncsExts.zip
>
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Vahid N. (JIRA) <nh...@gm...> - 2011-05-17 16:18:49
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vahid Nasiri updated NH-2683:
-----------------------------
Attachment: ProjectionsExtensions.zip
A new patch has been attached.
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
> Attachments: ProjectionsExtensions.zip, QueryOverSqlFuncsExts.zip
>
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Richard B. (JIRA) <nh...@gm...> - 2011-05-22 10:22:44
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21144#action_21144 ]
Richard Brown commented on NH-2683:
-----------------------------------
Thanks vahid. The new patch looks good. And I like renaming the Year() extension to YearPart() (makes it clearer it's an NH customisation).
Cheers.
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
> Attachments: ProjectionsExtensions.zip, QueryOverSqlFuncsExts.zip
>
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Richard B. (JIRA) <nh...@gm...> - 2011-05-22 13:30:42
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21146#action_21146 ]
Richard Brown commented on NH-2683:
-----------------------------------
Committed. Thanks. Just a reminder, for any future patches, that the NH code uses hard-tabs.
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
> Attachments: ProjectionsExtensions.zip, QueryOverSqlFuncsExts.zip
>
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Vahid N. (JIRA) <nh...@gm...> - 2011-05-22 14:52:42
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21147#action_21147 ]
Vahid Nasiri commented on NH-2683:
----------------------------------
OK. Thank you.
Yes, I saw that when I created the patch. everything in the diff file was red because of that tabbing style! :)
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
> Attachments: ProjectionsExtensions.zip, QueryOverSqlFuncsExts.zip
>
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Richard B. (JIRA) <nh...@gm...> - 2011-06-04 19:22:03
|
[ http://216.121.112.228/browse/NH-2683?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Richard Brown resolved NH-2683.
-------------------------------
Resolution: Fixed
Fix Version/s: 3.2.0Beta2
> Add common dialect functions as extension methods for QueryOver
> ---------------------------------------------------------------
>
> Key: NH-2683
> URL: http://216.121.112.228/browse/NH-2683
> Project: NHibernate
> Issue Type: Improvement
> Components: QueryOver
> Affects Versions: 3.2.0Alpha2
> Reporter: Richard Brown
> Assignee: Richard Brown
> Priority: Minor
> Fix For: 3.2.0Beta2
>
> Attachments: ProjectionsExtensions.zip, QueryOverSqlFuncsExts.zip
>
>
> Some of the common functions (that are registered in most, if not all Dialects) can be used in ICriteria using SQL-projections.
> Extensions methods can be added for these to allow queries along the lines of:
> s.QueryOver<Person>()
> .Where(p => p.BirthDate.Year() == 1970)
> .List()
> ... which can be translated to:
> .Where(Restrictions.Eq(Projections.SqlFunction("year", NHibernateUtil.DateTime, Projections.Property<Person>(p => p.BirthDate)), 1970))
> ... and in turn to:
> datepart(year, this_.BirthDate) = @p0;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|