Exemple #1
0
        /// <summary>
        /// It's fast and not a thread-safety version of ReplaceRows method.
        /// TODO: remove it after sqlite thread-safety refactoring.
        /// </summary>
        /// <param name="rows"></param>
        /// <returns></returns>
        public Int64 ReplaceRowsTrans(IEnumerable <ITableRow> rows)
        {
            Int64 result = 0L;

            using (OpenCloseConnectionWrapper wrapper = this.Connection.OpenWrapper())
            {
                using (SQLiteTransaction transaction = wrapper.Connection.BeginTransaction())
                {
                    ReplaceCommand replaceCommand = new ReplaceCommand(
                        wrapper.Connection,
                        this.TableDefinition,
                        transaction
                        );

                    foreach (ITableRow row in rows)
                    {
                        replaceCommand.AddRowForReplacing(row);
                    }

                    result = replaceCommand.Execute(100);

                    transaction.Commit();
                }
            }

            return(result);
        }
        /// <summary>
        /// Replace rows
        /// </summary>
        /// <param name="rows">Rows to be replaces</param>
        public Int64 ReplaceRows(IEnumerable <ITableRow> rows)
        {
            Int64 result = 0L;

            using (this.Connection.OpenWrapper())
            {
                ReplaceCommand replaceCommand = new ReplaceCommand(
                    this.Connection,
                    this.TableDefinition
                    );

                foreach (ITableRow row in rows)
                {
                    replaceCommand.AddRowForReplacing(row);
                }

                result = replaceCommand.Execute(100);
            }

            return(result);
        }