blob: f1ed7749248e6c71d167c9c79ada3435609f768c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
using System;
using System.Data;
using System.Data.SQLite;
namespace MediaBrowser.Controller.Persistence.SQLite
{
/// <summary>
/// Class SQLiteExtensions
/// </summary>
static class SQLiteExtensions
{
/// <summary>
/// Adds the param.
/// </summary>
/// <param name="cmd">The CMD.</param>
/// <param name="param">The param.</param>
/// <returns>SQLiteParameter.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
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;
}
/// <summary>
/// Adds the param.
/// </summary>
/// <param name="cmd">The CMD.</param>
/// <param name="param">The param.</param>
/// <param name="data">The data.</param>
/// <returns>SQLiteParameter.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
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;
}
/// <summary>
/// Determines whether the specified conn is open.
/// </summary>
/// <param name="conn">The conn.</param>
/// <returns><c>true</c> if the specified conn is open; otherwise, <c>false</c>.</returns>
public static bool IsOpen(this SQLiteConnection conn)
{
return conn.State == ConnectionState.Open;
}
}
}
|