I've looked at the existing threads trying to find the problem, but it seems to be a lot related to GetDbCount, so I'm sorry if it is dublicate.
The problem is that when getting data for the grid I need to get a total record count to calculate number of pages and show user amount of records.
I'm trying to use Adapter.GetDbCount method accepting the fields, relations, group by and
I want the query to be as effective as it is possible, so one of the things I'm trying to do is basically remove the fields so that it would do something like
select count() from (select id from ...) instead of select count() from (select id, all the fields ..... from ...)
May be it is not worth doing it, but that's another question.
In my case it is throwing an error:
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException : An exception was caught during the execution of a retrieval query: The multi-part identifier "net.metType.IsSystem" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
----> System.Data.SqlClient.SqlException : The multi-part identifier "net.metType.IsSystem" could not be bound.
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.ExecuteScalar() in RetrievalQuery.cs: line 155
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteScalarQuery(IRetrievalQuery queryToExecute) in DataAccessAdapterBase.cs: line 466
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.GetDbCount(IEntityFields2 fields, IRelationPredicateBucket filter, IGroupByCollection groupByClause, Boolean allowDuplicates) in DataAccessAdapterBase.cs: line 432
when I'm doing this:
using (var adapter = ...)
{
var fields = new ResultsetFields(1);
fields.DefineField(ObjectFields.Id, 0);
var bucket = new RelationPredicateBucket(ObjectFields.IsSystem == 0);
var count = adapter.GetDbCount(fields, bucket, null, true);
Assert.That(count, Is.EqualTo(317));
}
ObjectEntity is inherited from TypeEntity and field isSystem is stored in TypeEntity table.
I use TargetPerEntity inheritance Adapter templates, latest version of llblgen 2.6.10.930.
Let me know if you need anything else.
Anton