I have a custom control that inherits the standard ASP.NET DropDownList that I built a while ago to bind to tables that contain lookup data.
I set the data object name that I want to bind the control to as a property on my form and then use Reflection and the EntityCollectionBase class in the control to generate my collection.
This all works fine:
System.Reflection.Assembly asm = System.Reflection.Assembly.Load("Sequence.FiveCounties.DAL");
SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase inst = (SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase)asm.CreateInstance("Sequence.FiveCounties.DAL.CollectionClasses." + dataObject + "Collection");
inst.GetMulti(null);
Thing is because of one thing and another I need to sort the items before calling DataBind(). I've happily added some properties, so things like field name in the collection, direction, that sort of thing, but calling Sort on a Collection requires the FieldIndex as an int. I cannot do the normal (int)MyEntityFieldIndex.MyFieldName because I cannot have the individual collections field indexes as properties, I want to be able to pass in a string for the name.
Is there a way of getting from say a string "MyFieldName" to (int)MyEntityFieldIndex when the collection is not generated until run time?
Thanks.