Database Reference
In-Depth Information
described previously. Within this method, a column is added in front of all the others, which carries the
GUID. In the following code extract, line 3 creates the data column of type string , and line 4 sets its
default value to the connection's GUID. Line 7 fills the data table with the query's result, along with the
added GUID column. The following is the logic used to add this GUID:
1)
// Add the connection GUID to this set of records
2)
// This helps us identify which row came from which connection
3)
DataColumn col = dt.Columns.Add(_GUID_, typeof(string));
4)
col.DefaultValue = connection.ConnectionGuid();
5)
6)
// Get the data
7)
da.Fill(dt);
Caching
To minimize roundtrips to the source databases, the shard library provides an optional caching
mechanism. The caching technique used in this library offers basic capabilities and can be extended to
address more complex scenarios. The objective of this library is to cache the entire DataTable of each
database backend whenever requested. Figure 10-6 shows the logical decision tree of the caching
approach. It's important to note that this library calculates a cache key based on each parameter, the
parameter value, each SQL statement, and the database's GUID.
Figure 10-6. Caching logic
Search WWH ::




Custom Search