1、整体更新

2、自动部分更新

 

3、指定字段手动更新

        public bool Update(long waybillId,long so_header_id, long shipment_order_id, string package_no,NumberStatusType statusType)
        {
            bool isOk = false;
            using (B2C.DAL.DbWaybillContext context = new DAL.DbWaybillContext(ExpressWaybill.GetWriteConnectionString()))
            {
                this.TurnOnConsoleLog(context);
                B2C.Model.Waybill.ExpressWaybillNumberDTO entity = new Model.Waybill.ExpressWaybillNumberDTO();
                entity.Id = waybillId;
                entity.so_header_id = so_header_id;
                entity.ShipOrderId = shipment_order_id;
                entity.PackageNO = package_no;
                entity.NumberStatus = statusType;

                var entityEntry = context.Entry<B2C.Model.Waybill.ExpressWaybillNumberDTO>(entity);
                entityEntry.State = System.Data.Entity.EntityState.Unchanged;
                entityEntry.Property("so_header_id").IsModified = true;
                entityEntry.Property("ShipOrderId").IsModified = true;
                entityEntry.Property("PackageNO").IsModified = true;
                entityEntry.Property("NumberStatus").IsModified = true;
                context.Configuration.ValidateOnSaveEnabled = false;
                int rowsAffected = context.SaveChanges();
                if (rowsAffected > 0)
                    isOk = true;
                context.Configuration.ValidateOnSaveEnabled = true;
            }
            return isOk;
        }

 

相关文章:

  • 2021-11-22
  • 2022-02-17
  • 2022-01-09
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-08
  • 2022-12-23
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
相关资源
相似解决方案