MrAntunes
12/29/2016 - 1:16 PM

object properties check if IsAnyNullOrEmpty List<string> obrCol >>> nomes das propriedades a verificar

object properties check if IsAnyNullOrEmpty

List obrCol >>> nomes das propriedades a verificar

public bool IsAnyNullOrEmpty(object obj, List<string> obrCol)
        {
            foreach (PropertyInfo pi in obj.GetType().GetProperties())
            {
                foreach (string col in obrCol)
                {
                    if (pi.Name == col)
                    {
                        string value = pi.GetValue(obj)?.ToString() ?? "";
                        if (string.IsNullOrEmpty(value))
                        {
                            return true;
                        }
                    }
                }                   
            }
            return false;
        }