You can use reflection (this assumes that codeboth nameare properties, if they are public variables, you will have to change accordingly):
model = (sort.Direction == SortDirection.Ascending)
? model.OrderBy( x => x.GetType()
.GetProperty( sort.Column ).GetValue( x, null ) ) :
: model.OrderByDescending( x => x.GetType()
.GetProperty( sort.Column ).GetValue( x, null ) );
, , , . , , . model Foo, :
var prop = typeof( Foo ).GetProperty( sort.Column );
model = (sort.Direction == SortDirection.Ascending)
? model.OrderBy( x => prop.GetValue( x, null ) ) :
: model.OrderByDescending( x => prop.GetValue( x, null ) );
, TargetException, .