是否可以在 EF Code-First 中使用存根对象在不查询 db 中的整行的情况下进行更新,...
例如
public class Dinner
{
public int DinnerID { get; set; }
public string Title { get; set; }
public DateTime EventDate { get; set; }
public string Address { get; set; }
public string Country { get; set; }
public string HostedBy { get; set; }
}
Dinner dinner = dinner.DinnerID = 1;
dinner.HostedBy = "NameChanged"
nerdDinners.SaveChanges();
上面的代码是否会创建一个更新语句,这将使 DinnerID 1 的行的以下列为空?
标题、事件日期、地址、国家
有没有像“PropertyModified” = true 的方式或方法,然后其余的使它们 = false,以便 HostedBy 是唯一将被更新的?