ADO.NET Entity Framework : Using EntityClient and EntitySQL

Using Entity Framework with LINQ is simple and fun stuff. But if you are concerned about the performance and comfortable writing ADO.NET like code then EntityClient is for you. It resides under System.Data.EntityClient namespace. If you are using it you also need to use the EntitySQL (not T-SQL) so the query will be little different. Here is a first look to it,

using (EntityConnection conn =

    new EntityConnection("name=NorthwindEntities"))

{

    conn.Open();

    //EntitySQL

    string sQueryString = "SELECT VALUE e FROM " +

        " NorthwindEntities.Customers AS e";

    using (EntityCommand comm =

        new EntityCommand(sQueryString,conn))

    {

        EntityDataReader reader =

            comm.ExecuteReader(CommandBehavior.SequentialAccess);

        while (reader.Read())

        {

            Console.WriteLine(reader["CompanyName"]);

        }

    }

}

Namoskar!!!