public void GenerateEventsIntoDb(int count) { //Creating an amount of items on the entry int indexOfFirstPlace = Places.IndexOf(Places.FirstOrDefault(p => p.Name == "p0")); for (var i = 0; i < count; i++) { var tk = new Token("Token_" + i.ToString(), Places.ElementAt(indexOfFirstPlace)); Tokens.Add(tk); Places.ElementAt(indexOfFirstPlace).Capacity++; DbConn.Pn_InsertNewToken(tk); Event ev = GenerateNextEvent(Tokens.Last()); //DbConn.Pn_InsertEvent(ev); while (ev != null) { DbConn.Pn_InsertEvent(ev); ev = GenerateNextEvent(Tokens.Last()); } } }