我已經由實體框架生成以下兩類..不更新數據庫
public partial class Datagrid
{
public int Id { get; set; }
public string Name { get; set; }
public string Location { get; set; }
public Nullable<bool> IsChecked { get; set; }
}
public partial class SampleDbContext : DbContext
{
public SampleDbContext()
: base("name=SampleDbContext")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Datagrid> Datagrids { get; set; }
}
我有一個WPF應用程序,其中我有一個包含對於每一列checkboxs列表視圖..我寫的邏輯到找到在列表視圖中選中的複選框..但是,當我遍歷檢查框並嘗試保存到數據庫時,數據庫沒有更新,請幫助.. dg是Datagrid類型的對象.. db是SampleDbContext類型的對象
foreach (CheckBox cb in myBoxes)
{
dg.IsChecked = cb.IsChecked; //I want to update each column with the checked value in the listview. cb.Ischecked works perfectly..It says true for the checkboxes that are checked else false
db.SaveChanges(); //NOT updating the database
}
'dg'每次如何設置? – UtopiaLtd 2014-09-18 21:50:28
Forevery在我的應用程序中的複選框,我想將複選框的值分配給數據庫中的位值爲Ischecked – nikhil 2014-09-18 22:38:09