pastebin

Paste Search Dynamic
Recent pastes
LoadCustomersAsync
  1. private async void LoadCustomersAsync() {  
  2.     using(EmployeeDbEntities ent = new EmployeeDbEntities()) {  
  3.         IdbConnection conn = (ent.Connection as EntityConnection).StoreConnection;  
  4.         conn.Open();  
  5.         using(DbCommand cmd = (DbCommand) conn.CreateCommand()) {  
  6.             var query = from p in ent.EmployeeDetails  
  7.             where p.Name.Contains("FN") && p.SurName.Contains("SN") && (p.Name + p.SurName).Length > 3  
  8.             select p;  
  9.             //Convert linq query to SQL statement for CommandText  
  10.             string str = ((ObjectQuery) query).ToTraceString();  
  11.             cmd.CommandText = str;  
  12.             // Invoke Async flavor of ExecuteReader  
  13.             var task = await cmd.ExecuteReaderAsync();  
  14.             //translate retieved data to entity customer  
  15.             var cust1 = await Task.Run(  
  16.                 () => ent.Translate < EmployeeDetails > (task).ToList < EmployeeDetails > ());  
  17.             employeesDataGrid.ItemsSource = cust1;  
  18.         }  
  19.     }  
  20. }  
Parsed in 0.021 seconds