Walaa wrote:
1) if there are 200 records in the table and I pass
collection.GetMulti(filter, 10, sortExpression, relations, prefetchPath, excludedFields, 1, 100);
then also it returns me all 100 rows.. though i have set MaxRecord count = 10
from the name it apears that MaxCount must always get priority over PageSize
No, maxNumberOfItemsToReturn is ignored if paging is used.
2) Consider this.
I have around 1000 records in my DB.
and i fetch only 1 page of it having page size = 10
Everything is working fine but along with this I also want to know the total records in the DB for the given filter. So i have to make another call.
int RecordCount = collection.GetDbCount(filter, relations);
so in reality I am hitting DB twice once for getting the data for mage and second time for the count.
Is there any other way i get get the count as OUT parameter of GetMulti() ???
2 database hits are needed.
Can you get what you want with only one SQL query?
YES
Please consider this.
I have a table EMP with following data
ID sname
7 asd
1 asd
2 asd
44 asd
9 asdasd
Now i want paging as well as total number of record in one db hit
select TOP 3 ID, RecordCount = (select count (*) from EMP where sname = 'asd') from EMP where sname = 'asd'
Results
ID RecordCount
2 4
44 4
7 4
this requires only one DB hit.
what i want to say is
what if GetMulti Takes two more arguements
collection.GetMulti(list of usual param , bool isRecordCountRequired, ref int recordCount );
so i can pass my bunch of params and set
isRecordCountRequired = true and pass recordCount by reference and you can fill it with RecoundCount you received
if it is isRecordCountRequired = true then only construct the totalnumber record count querry else it will still behave as it used to behave earlier..
it will atleast help me in the kind of paging mechanism i have.
as for paging one must know how many pages are there.
I want to display a page at a time with 10 records but i also must know total number of records for the given filter to display number of pages link on UI.
will be waiting for your feedback for the same
Thanks
Ammit