熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ADO.NET Entity Framework 試水——並發[3]

2013-11-13 10:54:17  來源: .NET編程 

  
  當前數據庫情況如圖所示 

   第一步在概念模型設計器裡按照圖所示分別把NotebookBrand和NotebookType屬性的Concurrency Mode設置為Fixed 
  
  然後我們寫一段代碼來模擬一個並發沖突的情況 


  Create object context 
  
  Dim objContext As New NbWhEntities()
  
  Dim objContext As New NbWhEntities() 
   
   Query the same record as entities
  
  Dim laptop = (From aLaptop In objContextNotebook _
  
   Where aLaptopId = _
  
   Select aLaptop)FirstOrDefault() 
   
   Dim laptop = (From aLaptop In objContextNotebook _
  
   Where aLaptopId = _
  
   Select aLaptop)FirstOrDefault() 
   
Modify the entity

[]  []  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/14743.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.