﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Akal Tech RSS Feed</title><link>http://www.quickobjects.com/Views/Forum/Default.aspx</link><description>Akal Tech Forum Topics</description><copyright>Akal Tech (c) 2010. All rights reserved.</copyright><language>en-us</language><lastBuildDate>9/4/2010 7:04:41 PM GMT</lastBuildDate><item><title>Topic: Getting total record count in paging scenario</title><description>&lt;br&gt;Topic Description: &lt;P&gt;I was playing with the built-in paging capabilities:&lt;BR&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Setting PageIndex to the 0-based index of the desired page &lt;/LI&gt;
&lt;LI&gt;Setting PageSize to the number of records per page&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;However, I am unable to find a third property, that would supply total number of records in the database matching the search criteria. I need this third piece in order to calculate the total number of pages, for display in a paging control. AffectedRecords is equal to the number of records returned by the query (thus, is&amp;nbsp;&amp;lt;= PageSize). Calling Count() makes a second trip to the database, and does a COUNT(*) with no WHERE clause. Is there currently a means to obtain this information from the business object?&lt;BR&gt;&lt;BR&gt;Thanks!&lt;BR&gt;&lt;BR&gt;Thomas&lt;BR&gt;&lt;/P&gt;&lt;hr style="height:1px;"&gt;Replies: 3&lt;br&gt;Last Reply: Fri, 26 Dec 2008 14:30:38 GMT&lt;br&gt;Reply By: Ish Singh&lt;hr style="height:1px;"&gt;</description><link>http://www.quickobjects.com/Views/Forum/Topic.aspx?BPT=5&amp;PT=7&amp;APT=60</link><pubDate>Fri, 26 Dec 2008 14:30:38 GMT</pubDate></item><item><title>Reply: Re: Getting total record count in paging scenario</title><description>Hi Thomas,&lt;br&gt;&lt;br&gt;If you have the ObjectMode set to Search on the business object, as you load values into fields they get marked with UseInSearch = True. You can set the ObjectMode = None before loading the values this will ensure that only the fields originally marked for search will be included in where clause, however, the current loaded field values will be used.&lt;br&gt;&lt;br&gt;It is best to call the Count() immediately before or after the Find call. I have added an item in requested feature list that will automatically call the Count (when paging is turned on) and retain the value in the business object for later use.&lt;br&gt;&lt;br&gt;Happy Holidays!&lt;br&gt;Ish&lt;br&gt;</description><link>http://www.quickobjects.com/Views/Forum/Topic.aspx?BPT=5&amp;PT=7&amp;APT=60</link><pubDate>Fri, 26 Dec 2008 14:30:38 GMT</pubDate></item><item><title>Reply: Re: Getting total record count in paging scenario</title><description>Thanks Ish, this has been working well. I did notice one gotcha though. I'm not sure if this is only constrained to this scenario, but here is a brief description:&lt;br&gt;&lt;ol&gt;&lt;li&gt;Create a search entity, and set a couple of WHERE clause conditions. A couple of fields are made not visible.&lt;br&gt;&lt;/li&gt;&lt;li&gt;Left outer join this to another table entity. All fields set to not visible, then a couple of fields are made visible.&lt;/li&gt;&lt;li&gt;Paging set to return first page, page size is 15.&lt;br&gt;&lt;/li&gt;&lt;li&gt;I run search. Expected results are returned (1-15 of 78 records)&lt;/li&gt;&lt;li&gt;Here is the interesting part:&lt;/li&gt;&lt;ol&gt;&lt;li&gt;If I immediately call Count(), I get the correct result (78).&lt;/li&gt;&lt;li&gt;If I instead, retrieve the value of any one of the returned fields from the search, calling count now returns 0. An inspection of the SQL statement sent by Count() reveals that the field that was examined is now being incorporated into the WHERE clause.&lt;/li&gt;&lt;/ol&gt;&lt;/ol&gt;Not sure if this is by design or not, but since the fields are only being read (not changed), I would expect the WHERE clause used by Count() to also remain unchanged.&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;&lt;br&gt;Thomas&lt;br&gt;</description><link>http://www.quickobjects.com/Views/Forum/Topic.aspx?BPT=5&amp;PT=7&amp;APT=60</link><pubDate>Wed, 24 Dec 2008 17:00:30 GMT</pubDate></item><item><title>Reply: Re: Getting total record count in paging scenario</title><description>Hi Thomas,&lt;br&gt;&lt;br&gt;You have the correct idea of calling the Count() method, and it will make a second trip to database.&amp;nbsp; However, the Count is fairly trivial for a database to do (assuming you have a primary key/index on your table). &lt;br&gt;&lt;br&gt;Essentially, we could process both the Select and the Count statement within single call to the database using something called MARS, but that feature is not supported by all databases.&lt;br&gt;&lt;br&gt;&lt;br&gt;Here is a code sample on how to get the Count of all the records that match your search criteria. For this example, I hade 50000+ rows matching my criteria, but I only wanted 5 rows after skipping the first 5.&lt;br&gt;&lt;br&gt;&lt;div style="border: 1px solid rgb(127, 157, 185); overflow: auto; background-color: white; width: 100%; line-height: 100% ! important; font-family: Courier New; font-size: 11px;"&gt;&lt;table style="border-width: 0px; border-bottom: 0px solid rgb(238, 238, 238); margin: 2px 0px; width: 99%; border-collapse: collapse; background-color: rgb(255, 255, 255);" cellpadding="0" cellspacing="0"&gt;&lt;col style="border-bottom: 1px solid rgb(247, 247, 247); font-family: Courier New; font-size: 11px; padding-left: 10px; white-space: nowrap;"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;font style="font-size: 11px;"&gt;&lt;/font&gt;&lt;font style="color: blue;"&gt;using&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;(Customers&amp;nbsp;customer&amp;nbsp;=&amp;nbsp;&lt;/font&gt;&lt;font style="color: blue;"&gt;new&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;Customers())&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;{&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;customer.ObjectMode&amp;nbsp;=&amp;nbsp;Akal.QuickObjects.ObjectBase.ObjectModes.Search;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;customer.FirstName.StartsWith(&lt;font style="color: blue;"&gt;"FN"&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;);&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;customer.StartRowIndex&amp;nbsp;=&amp;nbsp;5;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;customer.PageSize&amp;nbsp;=&amp;nbsp;5;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: blue;"&gt;int&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;&amp;nbsp;count&amp;nbsp;=&amp;nbsp;customer.Count();&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: blue;"&gt;this&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;.GridView.DataSource&amp;nbsp;=&amp;nbsp;customer.Find();&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font style="color: blue;"&gt;this&lt;/font&gt;&lt;font style="font-size: 11px;"&gt;.GridView.DataMember&amp;nbsp;=&amp;nbsp;customer.GetResultSetName();&amp;nbsp;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="background-color: rgb(247, 247, 247);"&gt;}&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;br&gt;Hope that helps,&lt;br&gt;Ish&lt;br&gt; </description><link>http://www.quickobjects.com/Views/Forum/Topic.aspx?BPT=5&amp;PT=7&amp;APT=60</link><pubDate>Wed, 10 Dec 2008 22:51:49 GMT</pubDate></item></channel></rss>