public void CreateCollections() { int COUNT = 20; CatfishDbContext db = new CatfishDbContext(); List <CFEntityType> collectionTypes = db.EntityTypes.Where(t => t.TargetTypes.Contains(CFEntityType.eTarget.Collections.ToString())).ToList();//db.EntityTypes.Where(t => t.TargetType == EntityType.eTarget.Collections).ToList(); if (collectionTypes.Count == 0) { throw new Exception("No entity types have been defined for collections."); } var rand = new Random(); CollectionService srv = new CollectionService(db); for (int i = 0; i < COUNT; ++i) { CFEntityType cType = collectionTypes[rand.Next(0, collectionTypes.Count)]; CFCollection c = srv.CreateEntity <CFCollection>(cType.Id); string name = TestData.LoremIpsum(5, 10); c.SetName("Collection: " + name); c.SetDescription(TestData.LoremIpsum(20, 100, 1, 10)); c.Serialize(); db.Collections.Add(c); } db.SaveChanges(); }
private void CreateCollections() { List <int> ets = Ets.GetEntityTypes().ToList().Where(et => et.TargetTypesList.Contains(eTarget.Collections)).Select(et => et.Id).ToList(); for (int i = 0; i < TOTAL_COLLECTIONS; ++i) { int index = i % ets.Count; CFCollection c = Cs.CreateEntity <CFCollection>(ets[index]); c.SetName("Collection " + (i + 1)); c.SetDescription("Description for Collection " + (i + 1)); Cs.UpdateStoredCollection(c); } Db.SaveChanges(); }