经验总结16--EF局部更新数据
Jun 07, 2016 pm 03:58 PMEF提供更新某个实体的某些数据,而其他数据保留的功能。 1、重新实例一个实体,并给予ID和需要修改的字段。注:此处的实体不能从数据库中查询,只能新的实例。 Order order = new Order() { ID = id }; order.Name= test222; 2、包含该实体,更新策略为Uncha
EF提供更新某个实体的某些数据,而其他数据保留的功能。
1、重新实例一个实体,并给予ID和需要修改的字段。注:此处的实体不能从数据库中查询,只能新的实例。
Order order = new Order() { ID = id };
order.Name= "test222";
2、包含该实体,更新策略为Unchanged,设置需要更新的字段。
DbEntityEntry
entry.State = EntityState.Unchanged;
entry.Property(o=>o.Name).IsModified = true;
3、提交更新。
db.SaveChanges();

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to fix Blizzard Battle.net update stuck at 45%?

Use ddrescue to recover data on Linux

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation!

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks

How to install Angular on Ubuntu 24.04

Slow Cellular Data Internet Speeds on iPhone: Fixes

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times.
