internal void Insert <T>(Guid guid, T doc) { apimapper api = new apimapper(_viewmanager, this); if (basetype == doc.GetType()) { View <T> view = _view as View <T>; if (view.Mapper != null) { view.Mapper(api, guid, doc); } } else if (mapper != null) { mapper(api, guid, doc); } // map objects to rows foreach (var d in api.emitobj) { api.emit.Add(d.Key, ExtractRows(d.Value)); } // delete any items with docid in view if (_view.DeleteBeforeInsert) { DeleteRowsWith(guid); } SaveAndIndex(api.emit); }
internal bool InsertTransaction <T>(Guid docid, T doc) { apimapper api = new apimapper(_viewmanager, this); if (basetype == doc.GetType()) { View <T> view = (View <T>)_view; try { if (view.Mapper != null) { view.Mapper(api, docid, doc); } } catch (Exception ex) { _log.Error(ex); return(false); } } else if (mapper != null) { mapper(api, docid, doc); } if (api._RollBack == true) { return(false); } // map emitobj -> rows foreach (var d in api.emitobj) { api.emit.Add(d.Key, ExtractRows(d.Value)); } //Dictionary<Guid, List<object[]>> rows = new Dictionary<Guid, List<object[]>>(); tran_data data = new tran_data(); if (_transactions.TryGetValue(Thread.CurrentThread.ManagedThreadId, out data)) { // TODO : exists -> merge data?? } else { data = new tran_data(); data.docid = docid; data.rows = api.emit; _transactions.Add(Thread.CurrentThread.ManagedThreadId, data); } return(true); }