Example #1
0
        public static void Update(IUpdateEntityWithChanges <TEntity> msg)
        {
            try
            {
                using (var ctx = new TDBContext())
                {
                    TDBEntity entity;//
                    if (msg.EntityId == 0)
                    {
                        entity = new TDBEntity();
                        ctx.Set <TDBEntity>().Add(entity);
                    }
                    else
                    {
                        entity = ctx.Set <TDBEntity>().FirstOrDefault(x => x.Id == msg.EntityId);
                    }


                    entity.ApplyChanges(msg.Changes);

                    ctx.SaveChanges(true);
                    EventMessageBus.Current.Publish(new EntityUpdated <TEntity>((TEntity)(object)entity, new StateEventInfo(msg.Process.Id, RevolutionData.Context.Entity.Events.EntityUpdated), msg.Process, Source), Source);
                }
            }
            catch (Exception ex)
            {
                PublishProcesError(msg, ex, typeof(IEntityUpdated <TEntity>));
            }
        }
 public static void UpdateEntity <TEntity>(this IUpdateEntityWithChanges <TEntity> msg) where TEntity : class, IEntity
 {
     EF7DataContext <TEntity> .Update(msg);
 }
Example #3
0
 public static void Update(IUpdateEntityWithChanges <TEntity> msg)
 {
     typeof(EntityRepository <, ,>).MakeGenericType(typeof(TEntity), EntityType, ctxType)
     .GetMethod("Update")
     .Invoke(null, new object[] { msg });
 }