2011-03-31 206 views
1

行上執行更新我想更新一排這樣的:從實體框架

update [approvers] set approvalstatus = True Where approvalstatus = False and bookingID = @bookingid and approveremail = @email 

使用實體框架。

我有我的查詢應該像這樣提供的資料:

Dim db As New Model.Entities 
Dim approvers = From a In db.approvers Where a.ApprovalStatus = False And a.BookingID = BookingID And a.ApproverEmail = UserName Select a.ApprovalStatus 

我如何下一個目標該記錄更新,這樣我就可以設置a.approvalStatus = True,那麼這些改動提交到數據庫?

謝謝。

+0

破解它,謝謝。 – Phil 2011-03-31 11:14:38

回答

5
Dim approver As Model.Approvers = (From a In db.Approvers Where a.ApprovalStatus = False And a.ApproverEmail = UserName And a.BookingID = BookingID).First 

     approver.ApprovalStatus = True 
     db.SaveChanges()