public Form1() { InitializeComponent(); this.data = new RadGridViewEFCodeFirstData(); if (!data.OrderTypes.All().Any() || !data.Orders.All().Any() || !data.Shippers.All().Any()) { DataGenerator.PopulateData(this.data); } this.SetUpGrid(); this.FormClosing += Form1_FormClosing; }
public static void PopulateData(IRadGridViewEFCodeFirstData data) { for (int i = 1; i <= 100; i++) { OrderType orderType = new OrderType() { OrderTypeId = i, Description = "Test" + i }; Order order = new Order() { OrderId = i, Description = "Description" + i, OrderTypeId = orderType.OrderTypeId }; Shipper shipper = new Shipper() { ShipperId = i, Name = "Name " + i, OrderTypeId = orderType.OrderTypeId, Address = "Address " + i, }; data.OrderTypes.Add(orderType); data.Orders.Add(order); data.Shippers.Add(shipper); if (i % 100 == 0) { data.SaveChanges(); } } data.SaveChanges(); }