比如如下代码
public
void
Update<TEntity>(TEntity entity,
string
[] properties) where TEntity :
class
{
var entry =
base
.Entry(entity);
if
(entry.State == EntityState.Detached)
{
this
.Set<TEntity>().Attach(entity);
}
foreach
(var propertyName
in
properties)
{
entry.Property(propertyName).IsModified =
true
;
}
}