-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntityWithAssociations.cs
54 lines (46 loc) · 1.33 KB
/
EntityWithAssociations.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using SQLite;
using System.Collections.Generic;
namespace Kimchi
{
public interface IEntityWithAssociations
{
int Id { get; set; }
void BeforeInsert(SQLiteConnectionWrapper db);
void AfterInsert(SQLiteConnectionWrapper db);
void AfterUpdate(SQLiteConnectionWrapper db);
void AfterDelete(SQLiteConnectionWrapper db);
void AfterLoad(SQLiteConnectionWrapper db);
}
public abstract class Entity
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
}
public abstract class EntityWithAssociations: Entity, IEntityWithAssociations
{
#region IEntity implementation
public virtual void BeforeInsert(SQLiteConnectionWrapper db)
{
// do nothing
}
public virtual void AfterInsert(SQLiteConnectionWrapper db)
{
// do nothing
}
public virtual void AfterDelete(SQLiteConnectionWrapper db)
{
// do nothing
}
public virtual void AfterLoad(SQLiteConnectionWrapper db)
{
// do nothing
}
public virtual void AfterUpdate(SQLiteConnectionWrapper db)
{
// Usually we want to do the same thing on insert and on update
AfterInsert(db);
}
#endregion
}
}