2015-09-29 38 views
-2

我在相同的順序得到EF代碼第一個項目和種子法如何以完全相同的順序播種db?

situation2_1.RightActions.Add(new RightAction { ControlName = "HV1226-1", RightState = State.Off }); 
situation2_1.RightActions.Add(new RightAction { ControlName = "HV1227-1", RightState = State.Off }); 
situation2_1.RightActions.Add(new RightAction { ControlName = "HV2905-10", RightState = State.Off }); 
situation2_1.RightActions.Add(new RightAction { ControlName = "FV1010-1", RightState = State.Off }); 
situation2_1.RightActions.Add(new RightAction { ControlName = "FV1026-1", RightState = State.Off }); 
situation2_1.RightActions.Add(new RightAction { ControlName = "FV1415-1", RightState = State.Off }); 

播種數據庫記錄後,不會在代碼中 如何解決這個情況?

+1

你如何確定記錄不是「以相同的順序」。問題是什麼?你如何檢索記錄?你能不能簡單地做'按'訂單? – user1666620

回答

3

設計未定義數據庫記錄的「順序」。您可以依賴的唯一訂單是SELECT聲明中ORDER BY條款施加的訂單。

這意味着如果由於某種原因需要按照確切的順序從數據庫中獲取記錄,則必須明確強加它。