fork download
  1. using System;
  2. using static System.Console;
  3. using System.Collections.Generic;
  4. using System.ComponentModel.DataAnnotations;
  5. using System.ComponentModel.DataAnnotations.Schema;
  6. using System.Linq;
  7.  
  8. public class Program {
  9. public static void Main() {
  10. foreach (var c in GetColumns()) WriteLine(c);
  11. }
  12. private static IEnumerable<string> GetColumns() => typeof(Usuario).GetProperties()
  13. .Where(e => e.Name != "Id" && !(Attribute.GetCustomAttribute(e, typeof(NotMappedAttribute)) is NotMappedAttribute))
  14. .Select(e => e.Name);
  15. }
  16.  
  17. public class Usuario {
  18. [Required]
  19. public string Nome { get; set; }
  20.  
  21. [Required]
  22. public string Login { get; set; }
  23.  
  24. [Required]
  25. public string Password { get; set; }
  26.  
  27. [NotMapped]
  28. [Required]
  29. public string ConfirmPassword { get; set; }
  30. }
  31.  
  32. //https://pt.stackoverflow.com/q/362423/101
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(4,29): error CS0234: The type or namespace name `DataAnnotations' does not exist in the namespace `System.ComponentModel'. Are you missing an assembly reference?
prog.cs(5,29): error CS0234: The type or namespace name `DataAnnotations' does not exist in the namespace `System.ComponentModel'. Are you missing an assembly reference?
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty