Supports non-deterministic/db-side-only methods in Linq
Description
Some methods are non-deterministic and should not be evaluated in the expression tree, once and for all resulting rows, but instead in the database. This is the case for Guid.NewGuid() and Random.Next().
Others may have distinct resulting values depending on the host on which they execute, and can change the query results depending on whether they are evaluated on db-client side or on db-server side. This is the case for DateTime.Now, DateTime.UtcNow, DateTimeOffset.Now, DateTimeOffset.UtcNow.
Currently they are always evaluated by NHibernate Linq provider before emitting the query with the resulting value as a parameter.
They should be left in the expression tree, and translated to appropriate HQL standard functions, then translated to corresponding database functions.
A user wishing to have them evaluated client side will then have to put their value in a variable then use that variable in its query.
By the way, for supporting this feature, when registering a method/property for the linq provider, we should be able to tell if it is partially evaluatable or not.
Some methods are non-deterministic and should not be evaluated in the expression tree, once and for all resulting rows, but instead in the database. This is the case for
Guid.NewGuid()
andRandom.Next()
.Others may have distinct resulting values depending on the host on which they execute, and can change the query results depending on whether they are evaluated on db-client side or on db-server side. This is the case for
DateTime.Now
,DateTime.UtcNow
,DateTimeOffset.Now
,DateTimeOffset.UtcNow
.Currently they are always evaluated by NHibernate Linq provider before emitting the query with the resulting value as a parameter.
They should be left in the expression tree, and translated to appropriate HQL standard functions, then translated to corresponding database functions.
A user wishing to have them evaluated client side will then have to put their value in a variable then use that variable in its query.
By the way, for supporting this feature, when registering a method/property for the linq provider, we should be able to tell if it is partially evaluatable or not.