Program_Min.cs 828 B

12345678910111213141516171819202122232425262728
  1. using Vitorm;
  2. namespace App
  3. {
  4. public class Program_Min
  5. {
  6. static void Main2(string[] args)
  7. {
  8. // #1 Init
  9. using var dbContext = new Vitorm.Sql.SqlDbContext();
  10. dbContext.UseSqlite("data source=sqlite.db");
  11. // #2 Query
  12. var user = dbContext.Get<User>(1);
  13. var users = dbContext.Query<User>().Where(u => u.name.Contains("li")).ToList();
  14. }
  15. // Entity Definition
  16. [System.ComponentModel.DataAnnotations.Schema.Table("User")]
  17. public class User
  18. {
  19. [System.ComponentModel.DataAnnotations.Key]
  20. public int id { get; set; }
  21. public string name { get; set; }
  22. public DateTime? birth { get; set; }
  23. public int? fatherId { get; set; }
  24. }
  25. }
  26. }