/// <summary>
/// 修改
/// </summary>
/// <param name="bookInfo"></param>
/// <returns></returns>
public static bool Update(BookInfo bookInfo)
{
using (BookDBContext db = new BookDBContext())
{
//将实体附加到上下文中
db.BookInfo.Attach(bookInfo);
db.Entry<BookInfo>(bookInfo).Property(p => p.UnitPrice).IsModified = true;//更新指定的字段
int num = db.SaveChanges();
if (num > 0)
{
return true;
}
else
{
return false;
}
}
}