2015-06-23 187 views
1

我正在嘗試使用RavenDB(3.0)並試圖使用Bulk Insert功能。然而雖然批量插入似乎工作,我把它完成之後立即得到一個例外:Raven DB Bulk Insert的奇怪例外

An exception of type 'System.IO.EndOfStreamException' occurred in Raven.Client.Lightweight.dll but was not handled in user code 

Additional information: Attempted to read past the end of the stream. 

堆棧跟蹤

at Raven.Client.Connection.ObservableLineStream.<Start>b__1(Task`1 task) in c:\Builds\RavenDB-Stable-3.0\Raven.Client.Lightweight\Connection\ObservableLineStream.cs:line 39 
    at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke() 
    at System.Threading.Tasks.Task.Execute() 

這是我的代碼有:

static void Main(string[] args) 
{ 
    try 
    { 
     using (var store = new DocumentStore { 
        Url = "http://localhost:8080/", 
        DefaultDatabase = "Northwind" }) 
     { 
      store.Initialize(); 
      int total = 10000; 
      using (var bulkInsert = store.BulkInsert()) 
      { 
       for (int i = 0; i < total; i++){ 
        bulkInsert.Store(new Employee{ 
          FirstName = "FirstName #" + i, 
          LastName = "LastName #" + i}); 
         }       
        } 
       } 
      } 
    catch (Exception ex) 
    { 
     Console.WriteLine(ex); 
    } 
    finally 
    { 
     Console.ReadLine(); 
    } 
} 

奇怪的是數據被寫入數據庫(我可以在數據庫瀏覽器中查看它),但是也沒有發現異常在我的代碼中 - 它被標記爲未處理,儘管try/catch

我爲什麼可能會發生,更重要的是我怎麼能阻止它,我很沮喪。有人有主意嗎?

回答

2

這個例外來自我們用於批量插入的手錶。完成後,我們關閉手錶,並拋出異常。 它在內部處理,不應該有任何影響你的應用程序

+0

感謝澄清,我會忽略它然後:) –