예제 #1
0
        private PreparedSqlLiteInsertCommand CreateInsertCommand(SQLiteConnection conn, string extra)
        {
            var    cols = InsertColumns;
            string insertSql;

            if (!cols.Any() && Columns.Count() == 1 && Columns[0].IsAutoInc)
            {
                insertSql = string.Format("insert {1} into \"{0}\" default values", TableName, extra);
            }
            else
            {
                var replacing = string.Compare(extra, "OR REPLACE", StringComparison.OrdinalIgnoreCase) == 0;

                if (replacing)
                {
                    cols = InsertOrReplaceColumns;
                }

                insertSql = string.Format("insert {3} into \"{0}\"({1}) values ({2})", TableName,
                                          string.Join(",", (from c in cols
                                                            select "\"" + c.Name + "\"").ToArray()),
                                          string.Join(",", (from c in cols
                                                            select "?").ToArray()), extra);
            }

            var insertCommand = new PreparedSqlLiteInsertCommand(conn);

            insertCommand.CommandText = insertSql;
            return(insertCommand);
        }
예제 #2
0
 protected internal void Dispose()
 {
     if (_insertCommand != null)
     {
         _insertCommand.Dispose();
         _insertCommand = null;
     }
 }
예제 #3
0
 public PreparedSqlLiteInsertCommand GetInsertCommand(SQLiteConnection conn, string extra)
 {
     if (_insertCommand == null)
     {
         _insertCommand      = CreateInsertCommand(conn, extra);
         _insertCommandExtra = extra;
     }
     else if (_insertCommandExtra != extra)
     {
         _insertCommand.Dispose();
         _insertCommand      = CreateInsertCommand(conn, extra);
         _insertCommandExtra = extra;
     }
     return(_insertCommand);
 }