Click or drag to resize

DatabaseDBLookupCache Method

DBLookupCache is an enhancement to the existing DBLookup function. Ultimately we still use the same DBLookup mechanism to retrieve the required value but the result is cached to Thread Local Storage. Subsequent requests to lookup the same value (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 Object DBLookupCache(
	string column,
	string table,
	string where,
	DataFuncOptions options = ,
	string orderBy = null,
	string logSource = null
)

Parameters

column
Type: SystemString
An expression that identifies the field whose value you want to return. It can be a string expression identifying a field in a table or query, or it can be an expression that performs a calculation on data in that field.
table
Type: SystemString
A string expression identifying the set of records that constitutes the domain. It can be a table name or a view name.
where
Type: SystemString
A string expression used to restrict the range of data on which the DLookup function is performed. For example, criteria is often equivalent to the WHERE clause in an SQL expression, without the word WHERE. If criteria is omitted, the DLookup function evaluates expr against the entire domain. Any field that is included in criteria must also be a field in domain.
options (Optional)
Type: NetQuarryDataFuncOptions
A bitmask of DataFuncOptions enumeration flags.
orderBy (Optional)
Type: SystemString
An optional sort clause to include in the query.
logSource (Optional)
Type: SystemString
The source of the operation, to be logged to the devlog.

Return Value

Type: Object
The value in the column or null if no records are returned.

Implements

IDatabaseDBLookupCache(String, String, String, DataFuncOptions, String, String)
Remarks
Note that for performance reasons, this function does NOT check if multiple rows are returned from the query.
Examples
C#
// Lookup the first customer with a CompanyName that starts with Alfreds and print the value
object    val = db.DBLookup("CompanyName", "Customers", "CompanyName LIKE 'Alfreds%'");        
Console.WriteLine(val.ToString());

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