0

これは私が見つけた更新コードです:

using (TestDBEntities ctx = new TestDBEntities())
{
    //Get the specific employee from Database

    Emp e = (from e1 in ctx.Emp
         where e1.Name == "Test Employee"
         select e1).First();

    //Change the Employee Name in memory
    e.Name = "Changed Name";

    //Save to database
    ctx.SaveChanges();
}

今私がしていることはこのようなものです:

 using(CRNNSTestEntities crnnsupContext = new CRNNSTestEntities())
 {
     CPersonalInfo t = ((IQueryable<CPersonalInfo>)Cache["personquery"]).First();

     t.Tombstone.Address = Address1.Text;
     System.Windows.Forms.MessageBox.Show(crnnsupContext.SaveChanges()+"");
 };

これは機能しません。だから私の質問は私は次のようなものを書く必要がありますかCPersonalInfo t = from t in ....

なぜ私の方法が機能しないのですか?

ありがとう

4

3 に答える 3

0

以前にコンテキストにオブジェクトをアタッチすることもできます。

添付ファイルの使用方法の詳細はこちら

于 2012-04-04T13:43:21.907 に答える
0

あなたからではなく、あなたCPersonalInfo tからエンティティを取得する必要がありますcrnnsupContextCache

于 2012-04-04T13:04:40.580 に答える