Select Operation using ExecuteStoreQuery

Introduction

In this blog we will see how to perform select operation using executestorequery.

Program.cs

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Data.Entity.Infrastructure;  
  4. using System.Linq;  
  5. using System.Text;  
  6. using System.Threading.Tasks;  
  7. namespace ExecuteStoreQuery_Select   
  8. {  
  9.     class Program   
  10.     {  
  11.         static void Main(string[] args)   
  12.         {  
  13.             EmployeeEntities _dataContext = new EmployeeEntities();  
  14.             foreach(var r in (_dataContext as IObjectContextAdapter).ObjectContext.ExecuteStoreQuery < Employee > ("spSelectEmployee")) {  
  15.             Console.WriteLine(r);  
  16.             }  
  17.             Console.ReadKey();  
  18.         }  
  19.     }  
  20. }
Summary

In this blog we have seen how we can perform select operation using executestorequery. Happy coding!
MVC Corporation
MVC Corporation is consulting and IT services based company.