コード例 #1
0
        public void MapAndMerge(AbstractEntity entity, MappingEngineCollection mappers)
        {
            using (DisposableTimer.TraceDuration <NhSessionHelper>("Start MapAndMerge for entity " + entity.Id, "End MapAndMerge"))
                using (NhProfilerLogging.Start(NhSession, "MapAndMerge",
                                               new OdbcParameter("entity", entity)))
                {
                    var rdbmsEntity = mappers.MapToIntent <IReferenceByGuid>(entity);

                    // Track ID generation on the Rdbms object so that it can be pinged to the AbstractEntity upon Save/Update commit
                    rdbmsEntity = NhSession.Merge(rdbmsEntity) as IReferenceByGuid;

                    //InnerDataContext.NhibernateSession.SaveOrUpdate(rdbmsEntity);
                    mappers.Map(rdbmsEntity, entity, rdbmsEntity.GetType(), entity.GetType());
                }
        }
コード例 #2
0
        public void MapAndMerge <T>(Revision <T> entity, MappingEngineCollection mappers) where T : class, IVersionableEntity
        {
            HiveId hiveId   = entity.MetaData != null ? entity.MetaData.Id : HiveId.Empty;
            HiveId entityId = entity.Item != null ? entity.Item.Id : HiveId.Empty;

            using (DisposableTimer.TraceDuration <NhSessionHelper>("Start MapAndMerge for revision " + hiveId + " entity " + entityId, "End MapAndMerge"))
                using (NhProfilerLogging.Start(NhSession, "MapAndMerge<T> (Revision<T>)",
                                               new OdbcParameter("entity", entity)))
                {
                    var rdbmsEntity = mappers.MapToIntent <IReferenceByGuid>(entity);

                    // Track ID generation on the Rdbms object so that it can be pinged to the AbstractEntity upon Save/Update commit
                    rdbmsEntity = NhSession.Merge(rdbmsEntity) as IReferenceByGuid;

                    // 16th Jan 12 (APN) NH is not flushing if the above merged entity is queried before the transaction is committed, despite
                    // the flushmode being Auto. So, explicit call to Flush here pending a bugfix/ better solution
                    NhSession.Flush();

                    //InnerDataContext.NhibernateSession.SaveOrUpdate(rdbmsEntity);
                    mappers.Map(rdbmsEntity, entity, rdbmsEntity.GetType(), entity.GetType());
                }
        }