DB Count based on projection

Posts   
 
    
Sena
User
Posts: 22
Joined: 21-Jul-2021
# Posted on: 22-Apr-2022 11:35:59   

Hi,

Did do some searching but could not find it anywhere, is there an option to get the total count of rows based on a projection (used with FetchProjection)?

Best, Dick

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 22-Apr-2022 18:02:23   

Are these projections built from EntityFields, or how exactly did you get them?

Sena
User
Posts: 22
Joined: 21-Jul-2021
# Posted on: 25-Apr-2022 14:27:26   

Hi Walaa,

Yes, the projection is based on EntityFields and ultimately pushed into

void FetchProjection(List<IDataValueProjector> valueProjectors, IGeneralDataProjector projector, IEntityFields2 fields, IRelationPredicateBucket filter, int maxNumberOfItemsToReturn, ISortExpression sortClauses, IGroupByCollection groupByClause, bool allowDuplicates, int pageNumber, int pageSize);

Would it be possible to do a DbCount-like call using the same values except paging to have the database count the total number of rows instead of us fetching all rows before knowing the total count?

Best, Dick

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 25-Apr-2022 19:06:31   

There is an overload of the GetDBCount() method that accepts EntityFields. So all you need to do is to call it and pass the EntityFields, before doing your fetch.

Sena
User
Posts: 22
Joined: 21-Jul-2021
# Posted on: 25-Apr-2022 23:17:07   

Hi,

Awesome, found it! And got it running... thanks!

Best, Dick