Click or drag to resize

IDatabase.DBCountCache Method

Returns the number of items in the specified column and table using the SQL WHERE clause supplied. Note: For improved performance use DBExistsCache(String, String, DataFuncOptions, String) when possible. DBCountCache is an enhancement to the existing DBCount function. Ultimately we still use the same DBCount mechanism to retrieve the required value but the result is cached to Thread Local Storage. Subsequent requests to lookup the same count (using the SAME SQL) will pull that value from the thread cache rather than hitting the database.

Namespace:  NetQuarry
Assembly:  EAP.Core (in EAP.Core.dll) Version: 2.0.0.0 (4.6.8.0)
Syntax
int DBCountCache(
	string column,
	string table,
	string where,
	DataFuncOptions options = ,
	string logSource = null,
	int commandTimeout = 30
)

Parameters

column
Type: System.String
The name of the column from which to retrieve the value.
table
Type: System.String
The name of the table from which to retrieve the value.
where
Type: System.String
Filter criteria for which records to retrieve.
options (Optional)
Type: NetQuarry.DataFuncOptions
Option flags affecting the operation.
logSource (Optional)
Type: System.String
The source of the operation, to be logged to the devlog.
commandTimeout (Optional)
Type: System.Int32
The command timeout in seconds (overriding system default).

Return Value

Type: Int32
The number of matching records.
Examples
C#
// Lookup the first customer with a CompanyName that starts with Alfreds and print the value
object    val = db.DBLookupCache("CompanyName", "Customers", "CompanyName LIKE 'Alfreds%'");        
Console.WriteLine(val.ToString());

// Write the number of customers
Console.WriteLine(db.DBCountCache("*", "Customers", ""));
See Also