I am using VS 2010 LightSwitch in my application and want to apply filter using Preprocess query on some condition basis.
Like, i want to pass a global variable to that preprocess query to apply filter.
Code in Application.cs
public partial class Application
{
{
public static string filterType;
}
}
Code in ApplicationDataService.cs
partial void EmployeesSet_All_PreprocessQuery(ref IQueryable<Employees> query)
{
{
string filterType = this.Application.filterType; //// THIS LINE IS GIVING ERROR. But this is possible in code behind of screen. Any different approx to access global variable?
if (filterType == "Name")
{
query = query.OrderBy(t => t.Name);
}
else
{
query = query.Where(t => (t.Age < 28));
}
}
But, I am not able to access global variable filtertype from table code ApplicationDataService.cs.
Please suggest any way to implement this.
SOLUTION 1:
Go through “Defining Global Variable” Section.
No comments:
Post a Comment