private string[] ValidateFields(string indexName, IEnumerable <string> indexFields) { var withoutDuplicates = indexFields.Distinct().ToArray(); var members = _reflectionService.GetFieldsAndProperties(_classInfo.UnderlyingType); foreach (var indexField in withoutDuplicates) { var memberInfo = members.FirstOrDefault(x => x.Name.Equals(indexField)); var memberType = memberInfo is PropertyInfo ? ((PropertyInfo)memberInfo).PropertyType : ((FieldInfo)memberInfo).FieldType; if (memberInfo != null && (typeof(IComparable)).IsAssignableFrom(memberType)) { continue; } var fieldType = (memberInfo == null || memberInfo.DeclaringType == null) ? "Field doesn't exist" : memberType.FullName; throw new OdbRuntimeException(NDatabaseError.IndexKeysMustImplementComparable.AddParameter(indexName) .AddParameter(indexField) .AddParameter(fieldType)); } return(withoutDuplicates); }