Somwhere in the entity initialisation routine - sorry C#, I don't do VB past version 6!
Dictionary <string,EntityField2> lowercaseFieldNames = new Dictionary <string,EntityField2>();
foreach (EntityField2 field in entity.Fields)
{
lowercaseFieldNames.Add(field.Name.ToLower(),field);
}
In your function
return lowercaseFieldNames[fieldname.ToLower()];
If using .Net 3.5 just do it with LINQ (so you don't need the dictionary)
In your function
return entity.Fields.Single(x=>x.Name.ToLower() == fieldName.ToLower());