Click or drag to resize

DatabaseDBCountCache 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
public int DBCountCache(
	string column,
	string table,
	string where,
	DataFuncOptions options = ,
	string logSource = null,
	int commandTimeout = 30
)

Parameters

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

Return Value

Type: Int32
The number of matching records.

Implements

IDatabaseDBCountCache(String, String, String, DataFuncOptions, String, Int32)
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