Rob wrote:
Hi!
I find myself writing many and huge switch statements to get around issues which I hope will have a more dynamic capability (only I haven't found it out yet.)
There is a great collection in the EntityCollections called Fields. It is obviously for dynamic access to fields in the EntityClass.
private string testFunc(string sFieldName)
{
SomeTableCollection sometablecollection = new SomeTableCollection();
sometablecollection.GetMulti(null);
return sometablecollection.Fields[sFieldName].ToString();
}
This is great!
Err
I hope I won't spoil your party, but I'm not aware of a Fields collection in a collection. The entities inside a collection however have a fields collection. So you probably meant:
return sometablecollection[index].Fields[sFieldName].ToString(); ?
I now wonder if there is a similar appoach to the FieldIndex. I would like to be able to pass which field to sort on to a function. So far I have handled this by using Switch statements based on the sSortField argument. But that is a very cumbersome way to do it. Especially with many tables and Sort field candidates. I wonder if there is something like:
private string testFunc(string sSortField)
{
SomeTableCollection sometablecollection = new SomeTableCollection();
ISortExpression sorter = new SortExpression();
sorter.Add(SortClauseFactory.Create(SomeTableFieldIndex[sSortField], sortOperator.Ascending));
sometablecollection.GetMulti(null);
}
Is there some similar way to do this already?
Of course
private string testFunc(SomeTableFieldIndex index)
{
SomeTableCollection sometablecollection = new SomeTableCollection();
ISortExpression sorter = new SortExpression();
sorter.Add(new SortClause(EntityFieldFactory.Create(index), sortOperator.Ascending));
sometablecollection.GetMulti(null, ..... , sorter, ....);
}
This should do it