From 9fae975a53fbb852dfbaf811dca259ddd4f74f4c Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Thu, 26 Jun 2008 20:14:33 +0000 Subject: Apply patch from bug #1605 -- Documentation for Data/SQLite. Thanks kerunix_Flan! --- OpenSim/Data/SQLite/SQLiteUtils.cs | 64 ++++++++++++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 13 deletions(-) (limited to 'OpenSim/Data/SQLite/SQLiteUtils.cs') diff --git a/OpenSim/Data/SQLite/SQLiteUtils.cs b/OpenSim/Data/SQLite/SQLiteUtils.cs index 0862de0..18bb137 100644 --- a/OpenSim/Data/SQLite/SQLiteUtils.cs +++ b/OpenSim/Data/SQLite/SQLiteUtils.cs @@ -44,6 +44,12 @@ namespace OpenSim.Data.SQLite * **********************************************************************/ + /// + /// + /// + /// + /// + /// public static void createCol(DataTable dt, string name, Type type) { DataColumn col = new DataColumn(name, type); @@ -60,17 +66,24 @@ namespace OpenSim.Data.SQLite * **********************************************************************/ + /// + /// Create an insert command + /// + /// table name + /// data table + /// the created command + /// + /// This is subtle enough to deserve some commentary. + /// Instead of doing *lots* and *lots of hardcoded strings + /// for database definitions we'll use the fact that + /// realistically all insert statements look like "insert + /// into A(b, c) values(:b, :c) on the parameterized query + /// front. If we just have a list of b, c, etc... we can + /// generate these strings instead of typing them out. + /// public static SqliteCommand createInsertCommand(string table, DataTable dt) { - /** - * This is subtle enough to deserve some commentary. - * Instead of doing *lots* and *lots of hardcoded strings - * for database definitions we'll use the fact that - * realistically all insert statements look like "insert - * into A(b, c) values(:b, :c) on the parameterized query - * front. If we just have a list of b, c, etc... we can - * generate these strings instead of typing them out. - */ + string[] cols = new string[dt.Columns.Count]; for (int i = 0; i < dt.Columns.Count; i++) { @@ -95,6 +108,13 @@ namespace OpenSim.Data.SQLite return cmd; } + /// + /// create an update command + /// + /// table name + /// + /// + /// the created command public static SqliteCommand createUpdateCommand(string table, string pk, DataTable dt) { string sql = "update " + table + " set "; @@ -122,7 +142,11 @@ namespace OpenSim.Data.SQLite return cmd; } - + /// + /// + /// + /// Data Table + /// public static string defineTable(DataTable dt) { string sql = "create table " + dt.TableName + "("; @@ -158,15 +182,21 @@ namespace OpenSim.Data.SQLite **********************************************************************/ /// + /// /// This is a convenience function that collapses 5 repetitive /// lines for defining SqliteParameters to 2 parameters: /// column name and database type. - /// + /// + /// + /// /// It assumes certain conventions like :param as the param /// name to replace in parametrized queries, and that source /// version is always current version, both of which are fine /// for us. + /// /// + /// + /// ///a built sqlite parameter public static SqliteParameter createSqliteParameter(string name, Type type) { @@ -184,6 +214,11 @@ namespace OpenSim.Data.SQLite * **********************************************************************/ + /// + /// Type conversion function + /// + /// a type + /// a DbType public static DbType dbtypeFromType(Type type) { if (type == typeof (String)) @@ -224,8 +259,11 @@ namespace OpenSim.Data.SQLite } } - // this is something we'll need to implement for each db - // slightly differently. + /// + /// + /// a Type + /// a string + /// this is something we'll need to implement for each db slightly differently. public static string sqliteType(Type type) { if (type == typeof (String)) -- cgit v1.1