Querying with DbContext: Overview

Description and code samples
Table of Contents
Description

How to do it

Entity Framework queries are written using Linq To Entities ( .NET Framework feature Linq with provider Entity Framework).

A query is defined using the classes and properties that make up the entities model.

How it works
Entity Framework will submit a new query to the database every time an iteration is triggered over the contents of a DbSet. To re-use the query results if must first be copied to a collection object that implements the IEnumerable interface using an operator such IQueryable<T>.ToList().
Operations
The simplest query: Load all data for a specific entity type

Iterate over the contents of a specific DbSet

How to do it
using (var context = new BreakAwayContext())
  {
    foreach (var destination in context.Destinations)
    {
      Console.WriteLine(destination.Name);
    }
  }