Ejemplo n.º 1
0
 public EntityInfo(object entity, IdRev idrev, JToken doc, CouchDBViewRowKey key)
 {
     this.entity = entity;
     this.idrev  = idrev;
     this.doc    = doc;
     this.key    = key;
 }
Ejemplo n.º 2
0
        private EntitiesProcessResult PostProcess(
            PreProcessInfo preProcess, OdmViewProcessingOptions processingOptions)
        {
            var resultBuilder = new EntitiesProcessResultBuilder();

            foreach (PreProcessEntityInfo preProcessRow in preProcess.Rows)
            {
                JToken row = preProcessRow.Row;
                JToken doc = row[CouchDBFieldsConst.ResultRowDoc];
                if (doc == null)
                {
                    throw new Exception("doc field was not found");
                }

                string id    = preProcessRow.Id;
                string rev   = doc.Value <string>(CouchDBFieldsConst.DocRev);
                var    idrev = new IdRev(id, rev);

                object entity;
                if (idToEntity.TryGetValue(id, out entity))
                {
                    // PATCH: This line reload exist entities and should be remove in the future.
                    // The reason it is here is because when loading main entity with associated entity
                    // with many-to-many relations between them the related entity's assoication will
                    // be partially loaded and when updating the association of the related entity
                    // only part of the data will be avilable. This patch solve the problem
                    // but it will introduce inconsistensis and also cost in performance.
                    context.Serializer.ReFillProxy(entity, doc, id, preProcess, processingOptions);

                    // Reuse exist entity.
                    resultBuilder.AddExist(entity, idrev, doc, preProcessRow.Key);
                }
                else
                {
                    // Found new entity
                    entity = Deserialize(doc, preProcess, processingOptions);

                    idToEntity.Add(id, entity);
                    entityToId.Add(entity, id);

                    resultBuilder.AddNew(entity, idrev, doc, preProcessRow.Key);
                }
            }

            return(resultBuilder.BuildResult());
        }
Ejemplo n.º 3
0
 internal void AddExist(object entity, IdRev idrev, JToken doc, CouchDBViewRowKey key)
 {
     existEntities.Add(new EntityInfo(entity, idrev, doc, key));
 }