Exemplo n.º 1
0
        public void MirrorDelete(IList <int> docIds)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("delete from ");

            if (Table.DocIdReplaceField != null)
            {
                sql.AppendFormat(" {0} where {1} in (", Table.DBTableName, Table.DocIdReplaceField);
            }
            else
            {
                sql.AppendFormat(" {0} where docId in (", Table.DBTableName);
            }
            int i = 0;

            foreach (int docId in docIds)
            {
                long id;

                if (Table.DocIdReplaceField != null)
                {
                    id = this.DBProvider.GetDocIdReplaceFieldValue(docId);
                    if (id == long.MaxValue)
                    {
                        //does not find this record
                        continue;
                    }
                }
                else
                {
                    id = docId;
                }

                if (i++ == 0)
                {
                    sql.AppendFormat("{0}", id);
                }
                else
                {
                    sql.AppendFormat(",{0}", id);
                }
            }

            if (i == 0)
            {
                //No records need to delete
                return;
            }

            sql.Append(")");

            using (SQLiteDataProvider sqlData = new SQLiteDataProvider())
            {
                sqlData.Connect(Table.ConnectionString);
                sqlData.ExcuteSql(sql.ToString());
            }
        }