C# (CSharp) Azavea.Open.DAO.SQL Namespace

Classes

Name Description
AbstractSqlConnectionDescriptor This class represents the information needed to establish a connection to a data source that speaks SQL (presumably a database). This class, and any that extend it, should be thread safe.
DbCommandCache Holds DbCommands, we save them to allow us to reuse them (saves time).
DbConnectionCache Holds connections, using the connection descriptor to determine what request wants what connection.
SqlClauseWithValue Many SQL clauses look something like this: "(colName > 5)". However, on some DBs, that same clause may actually look like this: "LT_OR_EQ(5, colName)". To make things more complicated, you may want to not put 5 in the string, but use a parameter instead. So this allows you to represent it, in the first case PartBeforeValue would be "(colName > " and PartAfterValue would be ")", and in the second case PartBeforeValue would be "LT_OR_EQ(" and PartAfterValue would be ", colName)".
SqlConnectionUtilities This class holds static utility methods having to do with database access. The goal is twofold: 1: To reduce the number of lines of code required to to basic database stuff (if you're doing more complicated stuff, it may be appropriate to look at Azavea.Common.NHibernate and consider using NHibernate). 2: To ensure that connections are handled appropriately even in exception cases (I.E. they are closed and/or returned to the pool whether or not exceptions happen). Since no one likes obnoxiously long method names, "ExceptionSafe" has been abbreviated as "XSafe". There are two groups of methods, the "XSafe" query/command methods and the "DataSet" methods. The DataSet methods are provided primarily because some things (such as .NET controls) use DataSets directly. However, in general when writing new code you should use the XSafe methods, because they use DataReaders which are a faster way of accessing the database than DataSets. This class currently implements fairly primitive connection pooling. While .NET claims to do connection pooling for you, there is still a significant performance savings to be had by saving "DbConnection" objects and reusing them. The existing connection pooling basically saves one connection to any database you use this class to connect to. This achieves most of the savings that can be achieved with pooling, but if necessary a more complicated pooling scheme can be added in the future. Note that connection pooling is NOT used for all databases, since they may not support more than one "write" connection at a time.
SqlDaDdlLayer Base class for SQL-based data access layers that support DDL commands.
SqlDaJoinQuery A SQL query that joins two tables, can be run by the SqlDaLayer.
SqlDaLayer A SQL-specific implementation of an IDaLayer. Provided functionality to run data access function that are specific to data sources that take sql commands.
SqlDaQuery A "normal" SQL query, can be run by the SqlDaLayer.
SqlUtilities This class holds static utility methods having to do with constructing SQL statements (typically statements that would then be used with the SqlConnectionUtilities class). This class is stateless and thus is threadsafe.