Articles → LIGHT SWITCH 2011 → Preprocess query in lightswitch 2011

Preprocess query in lightswitch 2011




























Software requirement











Prerequisite knowledge











What is preprocess query





Scenario





Steps of execution

















Create a new project





Click to Enlarge


Add tables





Click to Enlarge


Click to Enlarge


Add screen





Click to Enlarge


Add data to tables





Click to Enlarge


Write preprocess query









Click to Enlarge



partial void Employees_All_PreprocessQuery(ref IQueryable<Employee> query)
{
   var setting = this.DataWorkspace.ApplicationData.SortSettingsSet.FirstOrDefault();
   if (setting != null)
   {
      if (setting.SortFieldName.CompareTo("NAME") == 0)
      {
         query = query.OrderBy(x => x.EmployeeName);
      }
      else if (setting.SortFieldName.CompareTo("DOJ") == 0)
      {
         query = query.OrderBy(x => x.DOJ);
      }
   }
}





Output



Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, April 03, 2013

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250