Database Reference
In-Depth Information
5.
The library should support mass or selective reads and writes.
Data returned by the library should be accepted as a data source for controls.
These requirements have very specific implications from a technology standpoint. Table 2-2
outlines which requirements are met by which technology.
6.
Table 2-2. Technologies Used to Build the Shard
Technology
Requirement
Comment
The configuration file stores the list of databases that make up
the shard.
Configuration file
1
Using the TPL lets the library to spawn multiple threads to use
computers with multiple CPUs, allowing parallel execution of
SQL statements.
Multithreading
2
Using SqlCommand objects allows the shard to connect to both
SQL Azure and SQL Server databases.
SqlClient
3
Caching lets the library store results temporarily to avoid
unnecessary roundtrips.
Caching
4
The library creates a virtual column for each record returned
that stores a breadcrumb identifying the database a record it
came from.
Breadcrumbs
5
The library returns a DataTable object that can be bound to
objects easily.
DataTable
6
Designing the Shard Library Object
The library accepts requests directly from client applications and can be viewed as an API. Note that
you're using extension methods to make this API blend in with the existing SqlCommand class; this in turn
minimizes the amount of code on the client and makes the application easier to read.
Figure 10-1 shows where the library fits in a typical application design. It also shows how the library
hides the complexity of parallel processing and caching from the client application. Finally, the shard
library abstracts the client code from dealing directly with multiple databases.
Search WWH ::




Custom Search