From e56433a0efe5bb69e9dbab796c12f9ca56346580 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 18 Jun 2013 05:43:07 -0400 Subject: sqlite --- .../Persistence/SqliteExtensions.cs | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs (limited to 'MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs') diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs new file mode 100644 index 0000000000..00dbbe513f --- /dev/null +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteExtensions.cs @@ -0,0 +1,61 @@ +using System; +using System.Data; +using System.Data.SQLite; + +namespace MediaBrowser.Server.Implementations.Persistence +{ + /// + /// Class SQLiteExtensions + /// + static class SqliteExtensions + { + /// + /// Adds the param. + /// + /// The CMD. + /// The param. + /// SQLiteParameter. + /// + public static SQLiteParameter AddParam(this SQLiteCommand cmd, string param) + { + if (string.IsNullOrEmpty(param)) + { + throw new ArgumentNullException(); + } + + var sqliteParam = new SQLiteParameter(param); + cmd.Parameters.Add(sqliteParam); + return sqliteParam; + } + + /// + /// Adds the param. + /// + /// The CMD. + /// The param. + /// The data. + /// SQLiteParameter. + /// + public static SQLiteParameter AddParam(this SQLiteCommand cmd, string param, object data) + { + if (string.IsNullOrEmpty(param)) + { + throw new ArgumentNullException(); + } + + var sqliteParam = AddParam(cmd, param); + sqliteParam.Value = data; + return sqliteParam; + } + + /// + /// Determines whether the specified conn is open. + /// + /// The conn. + /// true if the specified conn is open; otherwise, false. + public static bool IsOpen(this SQLiteConnection conn) + { + return conn.State == ConnectionState.Open; + } + } +} \ No newline at end of file -- cgit v1.2.3