Database Reference
In-Depth Information
context.Agents.Add(new Agent { Name = name1, Address = address1 });
context.Agents.Add(new Agent {Name = name2, Address = address2});
context.SaveChanges();
}
using (var context = new EF6RecipesContext())
{
Console.WriteLine("Agents");
foreach (var agent in context.Agents)
{
Console.WriteLine("{0} {1}", agent.Name.FirstName, agent.Name.LastName);
Console.WriteLine("{0}", agent.Address.AddressLine1);
Console.WriteLine("{0}", agent.Address.AddressLine2);
Console.WriteLine("{0}, {1} {2}", agent.Address.City,
agent.Address.State, agent.Address.ZIPCode);
Console.WriteLine();
}
}
The output of the code in Listing 2-27 is as follows:
Agents
Robin Rosen
510 N. Grant
Apt. 8
Raytown, MO 64133
Alex St. James
222 Baker St.
Apt.22B
Raytown, MO 64133
Search WWH ::




Custom Search