Beispiel #1
0
        /// <summary>
        /// Updates the doc, Returns the row index or -1
        /// </summary>
        public UpdateResult Update(Doc doc, Access.IDataStoreKey key = null, Func <Doc, Doc, Doc> docUpgrade = null)
        {
            Check(doc);
            var idx = DoUpdate(doc, key, docUpgrade);

            if (idx >= 0 && m_Changes != null)
            {
                m_Changes.Add(new DocChange(DocChangeType.Update, doc, key));
            }
            return(new UpdateResult(idx, true));
        }
Beispiel #2
0
        /// <summary>
        /// Tries to find a row with the same set of key fields in this table and if found, deletes it and returns its index, otherwise -1
        /// </summary>
        public int Delete(Doc doc, Access.IDataStoreKey key = null)
        {
            Check(doc);
            var idx = DoDelete(doc, key);

            if (idx >= 0 && m_Changes != null)
            {
                m_Changes.Add(new DocChange(DocChangeType.Delete, doc, null));
            }

            return(idx);
        }
Beispiel #3
0
        /// <summary>
        /// Tries to find a row with the same set of key fields in this table and if found, deletes it and returns its index, otherwise -1
        /// </summary>
        protected virtual int DoDelete(Doc doc, Access.IDataStoreKey key = null)
        {
            int dummy;
            int idx = SearchForDoc(doc, out dummy);

            if (idx < 0)
            {
                return(-1);
            }

            m_List.RemoveAt(idx);
            return(idx);
        }
Beispiel #4
0
        /// <summary>
        /// Tries to find a row with the same set of key fields in this table and if found, replaces it and returns its index,
        /// otherwise returns -1
        /// </summary>
        /// <param name="doc">Document instance</param>
        /// <param name="key">Primary key</param>
        /// <param name="docUpgrade">
        ///   When not null, is called with old and new instance of the doc to be updated. It returns
        ///   the doc to be saved. Note that the returned doc must have the same key and schema or else the function will throw.
        /// </param>
        protected virtual int DoUpdate(Doc doc, Access.IDataStoreKey key = null, Func <Doc, Doc, Doc> docUpgrade = null)
        {
            int dummy;
            var idx = SearchForDoc(doc, out dummy);

            if (idx < 0)
            {
                return(-1);
            }

            DoUpgrade(dummy, doc, docUpgrade);

            return(idx);
        }
Beispiel #5
0
 public DocChange(DocChangeType type, Doc doc, Access.IDataStoreKey key)
 {
     ChangeType = type;
     Doc        = doc;
     Key        = key;
 }