/// <summary> /// Get the fields that have been defined for the return entity of a method. /// </summary> /// <param name="methodInstance">The method to examine.</param> /// <returns>A collection of fields defined on the return entity of the the method.</returns> protected virtual ITypeDescriptorCollection GetEntityFields(Microsoft.BusinessData.MetadataModel.IMethodInstance methodInstance) { ITypeDescriptor returnType = methodInstance.GetReturnTypeDescriptor(); ITypeDescriptorCollection entityFields = null; if (returnType.IsCollection) { ITypeDescriptorCollection childTypes = returnType.GetChildTypeDescriptors(); if (childTypes.Count > 0) { entityFields = childTypes[0].GetChildTypeDescriptors(); } } else { entityFields = returnType.GetChildTypeDescriptors(); } return(entityFields); }