|
1 |
| -// Author: Prasanna V. Loganathar |
2 |
| -// Created: 2:37 PM 07-03-2015 |
3 |
| -// Project: SQLite.Net |
4 |
| -// License: See project license |
| 1 | +//using System; |
| 2 | +//using System.Linq; |
5 | 3 |
|
6 |
| -using System; |
7 |
| -using System.Linq; |
| 4 | +//namespace SQLite.Net2 |
| 5 | +//{ |
| 6 | +// internal class ActiveInsertCommand |
| 7 | +// { |
| 8 | +// private readonly TableMapping _tableMapping; |
| 9 | +// private PreparedSqlLiteInsertCommand _insertCommand; |
| 10 | +// private string _insertCommandExtra; |
8 | 11 |
|
9 |
| -namespace SQLite.Net2 |
10 |
| -{ |
11 |
| - internal class ActiveInsertCommand |
12 |
| - { |
13 |
| - private readonly TableMapping _tableMapping; |
14 |
| - private PreparedSqlLiteInsertCommand _insertCommand; |
15 |
| - private string _insertCommandExtra; |
| 12 | +// public ActiveInsertCommand(TableMapping tableMapping) |
| 13 | +// { |
| 14 | +// _tableMapping = tableMapping; |
| 15 | +// } |
16 | 16 |
|
17 |
| - public ActiveInsertCommand(TableMapping tableMapping) |
18 |
| - { |
19 |
| - _tableMapping = tableMapping; |
20 |
| - } |
| 17 | +// public PreparedSqlLiteInsertCommand GetCommand(SQLiteConnection conn, string extra) |
| 18 | +// { |
| 19 | +// if (_insertCommand == null) |
| 20 | +// { |
| 21 | +// _insertCommand = CreateCommand(conn, extra); |
| 22 | +// _insertCommandExtra = extra; |
| 23 | +// } |
| 24 | +// else if (_insertCommandExtra != extra) |
| 25 | +// { |
| 26 | +// _insertCommand.Dispose(); |
| 27 | +// _insertCommand = CreateCommand(conn, extra); |
| 28 | +// _insertCommandExtra = extra; |
| 29 | +// } |
| 30 | +// return _insertCommand; |
| 31 | +// } |
21 | 32 |
|
22 |
| - public PreparedSqlLiteInsertCommand GetCommand(SQLiteConnection conn, string extra) |
23 |
| - { |
24 |
| - if (_insertCommand == null) |
25 |
| - { |
26 |
| - _insertCommand = CreateCommand(conn, extra); |
27 |
| - _insertCommandExtra = extra; |
28 |
| - } |
29 |
| - else if (_insertCommandExtra != extra) |
30 |
| - { |
31 |
| - _insertCommand.Dispose(); |
32 |
| - _insertCommand = CreateCommand(conn, extra); |
33 |
| - _insertCommandExtra = extra; |
34 |
| - } |
35 |
| - return _insertCommand; |
36 |
| - } |
| 33 | +// protected internal void Dispose() |
| 34 | +// { |
| 35 | +// if (_insertCommand != null) |
| 36 | +// { |
| 37 | +// _insertCommand.Dispose(); |
| 38 | +// _insertCommand = null; |
| 39 | +// } |
| 40 | +// } |
37 | 41 |
|
38 |
| - protected internal void Dispose() |
39 |
| - { |
40 |
| - if (_insertCommand != null) |
41 |
| - { |
42 |
| - _insertCommand.Dispose(); |
43 |
| - _insertCommand = null; |
44 |
| - } |
45 |
| - } |
| 42 | +// private PreparedSqlLiteInsertCommand CreateCommand(SQLiteConnection conn, string extra) |
| 43 | +// { |
| 44 | +// var cols = _tableMapping.InsertColumns; |
| 45 | +// string insertSql; |
| 46 | +// if (!cols.Any() && _tableMapping.Columns.Count() == 1 && _tableMapping.Columns[0].IsAutoInc) |
| 47 | +// { |
| 48 | +// insertSql = string.Format("insert {1} into \"{0}\" default values", _tableMapping.TableName, extra); |
| 49 | +// } |
| 50 | +// else |
| 51 | +// { |
| 52 | +// var replacing = string.Compare(extra, "OR REPLACE", StringComparison.OrdinalIgnoreCase) == 0; |
46 | 53 |
|
47 |
| - private PreparedSqlLiteInsertCommand CreateCommand(SQLiteConnection conn, string extra) |
48 |
| - { |
49 |
| - var cols = _tableMapping.InsertColumns; |
50 |
| - string insertSql; |
51 |
| - if (!cols.Any() && _tableMapping.Columns.Count() == 1 && _tableMapping.Columns[0].IsAutoInc) |
52 |
| - { |
53 |
| - insertSql = string.Format("insert {1} into \"{0}\" default values", _tableMapping.TableName, extra); |
54 |
| - } |
55 |
| - else |
56 |
| - { |
57 |
| - var replacing = string.Compare(extra, "OR REPLACE", StringComparison.OrdinalIgnoreCase) == 0; |
| 54 | +// if (replacing) |
| 55 | +// { |
| 56 | +// cols = _tableMapping.Columns; |
| 57 | +// } |
58 | 58 |
|
59 |
| - if (replacing) |
60 |
| - { |
61 |
| - cols = _tableMapping.Columns; |
62 |
| - } |
| 59 | +// insertSql = string.Format("insert {3} into \"{0}\"({1}) values ({2})", _tableMapping.TableName, |
| 60 | +// string.Join(",", (from c in cols |
| 61 | +// select "\"" + c.Name + "\"").ToArray()), |
| 62 | +// string.Join(",", (from c in cols |
| 63 | +// select "?").ToArray()), extra); |
| 64 | +// } |
63 | 65 |
|
64 |
| - insertSql = string.Format("insert {3} into \"{0}\"({1}) values ({2})", _tableMapping.TableName, |
65 |
| - string.Join(",", (from c in cols |
66 |
| - select "\"" + c.Name + "\"").ToArray()), |
67 |
| - string.Join(",", (from c in cols |
68 |
| - select "?").ToArray()), extra); |
69 |
| - } |
70 |
| - |
71 |
| - return new PreparedSqlLiteInsertCommand(conn) |
72 |
| - { |
73 |
| - CommandText = insertSql |
74 |
| - }; |
75 |
| - } |
76 |
| - } |
77 |
| -} |
| 66 | +// return new PreparedSqlLiteInsertCommand(conn, insertSql); |
| 67 | +// } |
| 68 | +// } |
| 69 | +//} |
0 commit comments