@@ -7,34 +7,43 @@ using System;
77using System.Collections.Generic;
88using System.Linq;
99using SQLiteAbstractCrud;
10+ using SQLiteAbstractCrud.Proxy.Attributes;
1011
1112namespace Sample
1213{
1314 public class Program
1415 {
1516 static void Main(string[] args)
1617 {
18+ // 1. Create a repository class with RepositoryBase<T> as base
19+ // 2. Pass the path of the file db as constructor
1720 PersonRepository personRepository = new ("./my-db.db");
1821
1922 Console.WriteLine("\r\nSimple insert");
20- personRepository.Insert(new Person(false, "Bob"));
21- var person = personRepository.GetAll().First();
23+ personRepository.Insert(new Person(1, false, "Bob")); // insert
24+ var person = personRepository.GetAll().First(); // getAll
2225 Console.WriteLine(person.Name);
2326
2427 Console.WriteLine("\r\nBatch insert");
2528 var persons = new List<Person>
2629 {
27- new Person(false, "Mary"),
28- new Person(false, "John")
30+ new Person(2, false, "Mary"),
31+ new Person(3, false, "John")
2932 };
30- personRepository.InsertBatch(persons);
31- personRepository.GetAll().ToList().ForEach(person => Console.WriteLine(person.Name));
33+ personRepository.InsertBatch(persons); // insertBatch
34+ var people = personRepository.GetAll().ToList(); // getAll
35+ people.ForEach(person => Console.WriteLine(person.Name));
36+
37+ Console.WriteLine("\r\nDelete");
38+ personRepository.Delete(people[0].Id); // delete
39+ personRepository.GetAll().ToList().ForEach(person => Console.WriteLine(person.Name));// getAll
40+
41+ Console.ReadKey();
3242 }
3343 }
3444
3545
3646 // repository
37-
3847 public class PersonRepository : RepositoryBase<Person>
3948 {
4049 public PersonRepository(string pathDbFile) : base(pathDbFile)
@@ -45,29 +54,22 @@ namespace Sample
4554
4655
4756 // entity
48-
4957 public class Person
5058 {
5159 [PrimaryKey] // required
52- [AutoIncrement] // optional
5360 public int Id { get; set; }
54- public string Name { get; set; }
5561 public bool IsDriver { get; set; }
62+ public string Name { get; set; }
5663
5764 public Person(int id, bool isDriver, string name)
5865 {
5966 Id = id;
6067 IsDriver = isDriver;
6168 Name = name;
6269 }
63-
64- public Person(bool isDriver, string name)
65- {
66- IsDriver = isDriver;
67- Name = name;
68- }
6970 }
7071}
7172
7273
74+
7375```
0 commit comments