//create new parent object and new children objects public static void CreateObjectGraph() { using (var context = new EFDContext()) { var p = new Person() {FirstName = "Bob", LastName = "Rogden"}; p.Addresses.Add((new Address(){Street = "main street"})); //do you have to specify the person id or Person peroperty on the address or will it just work? //COOL, it just works context.People.Add(p); context.SaveChanges(); } }
static void Main(string[] args) { int countOfPerson = 2000000; for (int i = 0; i < 15; i++) { Person[] people = new Person[countOfPerson]; for (int j = 0; j < countOfPerson; j++) { people[j] = new Person(); people[j].FirstName = RandomString(); } myStopwatch.Start(); var orderedList1 = people.OrderByViaReflection("FirstName"); myStopwatch.Stop(); Console.WriteLine("Reflection method - " + myStopwatch.Elapsed.Milliseconds); myStopwatch.Reset(); myStopwatch.Start(); var orderedList2 = people.OrderByViaExpressions("FirstName"); myStopwatch.Stop(); Console.WriteLine("Expressions method - " + myStopwatch.Elapsed.Milliseconds); myStopwatch.Reset(); //File.WriteAllLines("reflection" + i + ".txt", orderedList1.Select<Person, string>(x => x.ToString()), Encoding.ASCII); //File.WriteAllLines("expressions" + i + ".txt", orderedList2.Select<Person, string>(x => x.ToString()), Encoding.ASCII); } Console.ReadKey(); }