Generic Call to GetScalar

Posts   
 
    
gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 22-Nov-2007 17:45:08   

Hi,

We're building a generic framework around LLBLGen, which means we can't use the actual entities in the framework but only Interfaces and BaseClasses. All in selfservicing.

Today we've tried to do GetScalar methods in this way. We need this to get a row count on a table (very big one, collection.getmulti(null).count is not an option).

The process: Initialize a [EntityName]DAO using Activator.CreateInstance(type) out of the .dll file (which is specified in the web.config) of the dataproject class and cast it as a IDao.

Then we run the IDao.GetScalar() and retrieve the result as an int:


// Get the resultset with paging
                this.entityCollection.GetMulti(null, -1, null, null, null, this.PagingCurrentPage, this.PagingPageSize);

// Get the dao class via our framework activator system
                IDao dao = Dionysos.DataFactory.EntityFactory.GetDao(this.EntityName) as IDao;

// Now getsclar to get rowcount
                if(this.entityCollection.Count > 0)
                {
                    dao.GetScalar(this.entityCollection[0].Fields, null, null, null, null);
                }

We do get an int as result, but it's not equal to: this.entityCollection.getmulti(null).count, the int returned by the scalar is different of that of the .count

I've got the idea i'm freestyling to far now and think I know what I am doing, but actually I am probably not. Who takes the very nice position of putting me back on my feet and tell me what I am doing completly wrong. If not so wrong, please tell me what I am missing.

Thanks a lot!

DvK
User
Posts: 323
Joined: 22-Mar-2006
# Posted on: 22-Nov-2007 21:56:25   

And what is the DbCount method returning ?

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 23-Nov-2007 09:34:30   

Grrrr wink

I didn't know about that function, I am always using scalars for this... Thanks!

Cheers, Gab

DvK
User
Posts: 323
Joined: 22-Mar-2006
# Posted on: 23-Nov-2007 12:36:52   

How's life in the land of application development ?

Danny !