This code...
KMI.Orm.CollectionClasses.VersionCollection versions = new KMI.Orm.CollectionClasses.VersionCollection();
versions.GetDbCount(new PredicateExpression(), new RelationCollection());
generates two very similar queries...
SELECT [dbo].[version].[VersionID] AS [VersionId], [dbo].[version].[Major], [dbo].[version].[Minor], [dbo].[version].[Revision], [dbo].[version].[VersionDate], [dbo].[version].[User], [dbo].[version].[Notes] FROM [dbo].[version]
SELECT COUNT(*) AS NumberOfRows FROM (SELECT [dbo].[version].[VersionID] AS [VersionId], [dbo].[version].[Major], [dbo].[version].[Minor], [dbo].[version].[Revision], [dbo].[version].[VersionDate], [dbo].[version].[User], [dbo].[version].[Notes] FROM [dbo].[version] ) TmpResult
Is there a way to avoid basically the same query being executed twice? In the case of non-trivial queries it hurts performance. I've tried using GetDbCount and GetScalar of DAO classes but always see two queries generated.
(This is with SQL Server 2005, version 2.6 of LLBLGen.)