Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        NorthwindEntities db = new NorthwindEntities();

        IEnumerable <Customers_By_City_Result> results =
            from c in db.Customers_By_City("London")
            select c;

        GridView1.DataSource = results;
        GridView1.DataBind();
    }
Ejemplo n.º 2
0
        static void Listing20_15()
        {
            Console.WriteLine("{0} : Begin", new StackTrace(0, true).GetFrame(0).GetMethod().Name);

            // create the ObjectContext
            NorthwindEntities context = new NorthwindEntities();

            IEnumerable <Customers_By_City_Result> custs = context.Customers_By_City("London");

            foreach (Customers_By_City_Result cust in custs)
            {
                Console.WriteLine("{0}, {1}", cust.CompanyName, cust.ContactName);
            }

            Console.WriteLine("{0} : End", new StackTrace(0, true).GetFrame(0).GetMethod().Name);
        }
    static void Main(string[] args)
    {
        // create a context
        NorthwindEntities context = new NorthwindEntities();

        // query the stored procedure
        IEnumerable <Customers_By_City_Result> results =
            from e in context.Customers_By_City("London")
            where !e.ContactName.Contains("Hardy")
            select e;

        foreach (Customers_By_City_Result item in results)
        {
            Console.WriteLine("Name: {0}", item.CompanyName);
        }

        // wait for input before exiting
        Console.WriteLine("Press enter to finish");
        Console.ReadLine();
    }