2015-09-29 37 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条款施加的订单。

这意味着如果由于某种原因需要按照确切的顺序从数据库中获取记录,则必须明确强加它。