2
I did a question how to use Sqlbulkcopy, the @Virgilionovic user showed me a code that uses Reflection to save any kind of list, but I do the TypeDescriptor.GetProperties() he brings the properties collection and virtual,  that would be binding, thus generating an error when trying to save in Baco.
I managed to remove the IEnumerable using that code:
var properties = TypeDescriptor.GetProperties(typeof(T))
                .Cast<PropertyDescriptor>()
                .Where(l=> l.PropertyType == typeof(string) ||   
                   !typeof(IEnumerable).IsAssignableFrom(l.PropertyType));
But I couldn’t remove the virtual classes, this and my class:
public class MensagemUnidade
{
        public int MensagemUnidadeId { get; set; }
        public string Titulo { get; set; }
        public string Texto { get; set; }
        public ICollection<FotoMensagemUnidade> Fotos { get; set; }
        public int UnidadeId { get; set; }
        public int ClienteId { get; set; }
        public virtual Cliente Cliente { get; set; }
        public virtual Unidade Unidade { get; set; }
}
In case I already managed to withdraw Fotos, but I had to take Cliente and Unidade , leaving only ClienteId and UnidadeId, if anyone knows a good way to do so would be grateful.
EDIT:
Adding the properties to the DataTable
foreach (PropertyDescriptor prop in properties)
            table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType)
                                         ?? prop.PropertyType);
But you need to use the
TypeDescriptorandPropertyDescriptor?– Jéf Bueno
I was seeing the difference between them Type and Typedescriptor, I’m only using because that’s how Victor passed me the other question, as I have little knowledge yet I haven’t changed, I’m studying.
– William Cézar