Timestamp on Object Creation
Sometimes, it may be useful to have a timestamp of when a database object is created. This can be done using an abstract class with a constructor that sets the timestamp.
In code, it would look something like this:
1
[Database]
2
public abstract class BaseOfAllOtherClasses
3
{
4
public DateTime Inserted { get; set; }
5
6
public BaseOfAllOtherClasses()
7
{
8
Inserted = DateTime.Now;
9
}
10
}
11
12
public class Foo : BaseOfAllOtherClasses {}
13
public class Bar : BaseOfAllOtherClasses {}
Copied!
From this, it is possible to get when all the instances were created chronologically by using the following query:
1
SELECT b.Inserted FROM BaseOfAllOtherClasses e ORDER BY e.Inserted
Copied!
Last modified 3yr ago
Copy link