The exception occurs on the call to .List.  It's as if the parameters
associated with detachedCriteria are being disassociated or aren't
coming through for some reason when the DetachedQuery is actually
executed.  This also fails if I use a CriteriaImpl instead of the
MultiCriteria:

                var itemCountCriteria =
DetachedCriteria.For(detachedCriteria.GetRootEntityTypeIfAvailable())
                    .SetMaxResults(1)
                    
.SetProjection(Projections.Count(Projections.SubQuery(detachedCriteria)));

            var multiList = session.CreateMultiCriteria()
                .Add(itemCountCriteria)
                .Add(detachedCopy)
                .List();


Incorrect syntax near '?'.
Incorrect syntax near '?'.
Incorrect syntax near '?'.
Incorrect syntax near '?'.

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

[SqlException (0x80131904): Incorrect syntax near '?'.
Incorrect syntax near '?'.
Incorrect syntax near '?'.
Incorrect syntax near '?'.]
   System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection) +1951450
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) +4849003
 
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) +194
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) +2394
   System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +33
   System.Data.SqlClient.SqlDataReader.get_MetaData() +83
   System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader
ds, RunBehavior runBehavior, String resetOptionsString) +297
 
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async) +954
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, DbAsyncResult result) +162
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) +32
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
behavior, String method) +141
 
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior
behavior) +12
   System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
+12
   NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)
+306
   NHibernate.Impl.MultiCriteriaImpl.GetResultsFromDatabase(IList
results) +463
   NHibernate.Impl.MultiCriteriaImpl.DoList() +66
   NHibernate.Impl.MultiCriteriaImpl.ListIgnoreQueryCache() +37
   NHibernate.Impl.MultiCriteriaImpl.List() +572

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to