Breeze BeforeSaveEntityonly only allows update to Added entities

后端 未结 2 1595
北荒
北荒 2021-01-12 02:44

Don\'t know if this is intended or a bug, but the following code below using BeforeSaveEntity will only modify the entity for newly created records (EntityState = Added), an

2条回答
  •  离开以前
    2021-01-12 03:17

    I had the same problem, and I solved that doing this:

    protected override bool BeforeSaveEntity(EntityInfo entityInfo)
    {
      if(entityInfo.EntityState== EntityState.Modified)
      {
         var entity = entityInfo.Entity;
         entityInfo.OriginalValuesMap.Add("ModificationDate", entity.ModificationDate);
         entity.ModificationDate = DateTime.Now;
      }
    }
    

    I think you can apply this easily to your case.

提交回复
热议问题