Using self servicing with version 2.6
I am trying to create a dynamic sort clause using the name of the field being passed in.
So this works for basic sort expressions:
string FieldName= "Title";
this.SortExpression.Add(new SortClause(new EntityField(FieldName, new Expression()), SortDirection));
Quite often I need to sort on a related field's related field (e.g. Account > User > Contact Details) and creating a new EntityField isn't working for that. Using a normal entityfield (i.e. ContactFields.FirstName) works fine.
So my question is, how do you get an entity field from a string with the field name? Is it possible to get the entity type as well?
Something like this:
string EntityName = "Contact";
string FieldName = "FirstName";
SortClause Sort = new SortClause(MagicFunction(EntityName, FieldName), SortOperator.Ascending)