O'Reilly logo

Pro C# 2010 and the .NET 4 Platform, Fifth Edition by Andrew Troelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

23.3. Programming Against the Conceptual Model

Now you can author some code that interacts with your EDM. Begin by updating your Program class to call a helper method from Main(), which will print out each item in the Inventory database using your conceptual model, and another which will insert a new record to the Inventory table:

class Program
{
  static void Main(string[] args)
  {
    Console.WriteLine("***** Fun with ADO.NET EF *****");
    AddNewRecord();
    PrintAllInventory();
    Console.ReadLine();
  }

  private static void AddNewRecord()
  {
    // Add record to the Inventory table of the AutoLot
    // database.
    using (AutoLotEntities context = new AutoLotEntities())
    {
      try
      {
        // Hard code data for a new record, for testing. context.Cars.AddObject(new Car() { CarID ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required