private void OnSortParametersByBindingPropertyNameEventRaised(object sender, DataEventArgs sortParameters) { var paramsDtos = facade.GetParametersDto(); switch (sortParameters.ModelDictionary["PropertyName"]) { case "Name": paramsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? paramsDtos.OrderBy(p => p.Name) : paramsDtos.OrderByDescending(p => p.Name); break; case "ProductName": paramsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? paramsDtos.OrderBy(p => p.ProductName) : paramsDtos.OrderByDescending(p => p.ProductName); break; case "UnitName": paramsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? paramsDtos.OrderBy(p => p.UnitName) : paramsDtos.OrderByDescending(p => p.UnitName); break; case "Value": paramsDtos = sortParameters.ModelDictionary["OrderOfSort"] == "Ascending" ? paramsDtos.OrderBy(p => p.Value) : paramsDtos.OrderByDescending(p => p.Value); break; } bindingSource.DataSource = paramsDtos; parametersUC.SetupControls(bindingSource); }