-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCode for default columns.txt
104 lines (81 loc) · 4.06 KB
/
Code for default columns.txt
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Please follow these instructions in order to get the defaule columns to be handeld by the project architecture.
"CreatedDate" is property/column where the creating date of record will be saved and will never change
"CreatedBy" is property/column where the id of user who created the record will be saved and will never change
"ModifiedDate" is property/column where the date when the record is last modified will be saved and will change upon every new update.
"ModifiedBy" is property/column where the id of user who modified the record will be saved and will change upon every new update.
"Trashed" is property/column which is used for soft deleting of record.
"RowVersion" is property/column which is used for maintaining the record version and will auto update on updating any column of the table.
"Status" is property/column which is used for maintaining the record status as "Active = true" or "In-Active = false".
1. CreatedDate (Property in model/column in database) or column with same feature
You can change the column name as per database in [Column] Attribute.
Do not change the property name because it is linked with interface.
Code:
[CreatedAt]
[IgnoreUpdate]
[Column("CreatedDate")]
public new DateTime? CreatedDate { get; set; }
2. CreatedBy (Property in model/column in database) or column with same feature
You can change the column name as per database in [Column] Attribute.
Do not change the property name because it is linked with interface.
Code:
[IgnoreUpdate]
[Column("CreatedBy")]
public new string CreatedBy { get; set; }
3. ModifiedDate (Property in model/column in database) or column with same feature
You can change the column name as per database in [Column] Attribute.
Do not change the property name because it is linked with interface.
Code:
[UpdatedAt]
[Column("ModifiedDate")]
public new DateTime? ModifiedDate { get; set; }
4. ModifiedBy (Property in model/column in database) or column with same feature
You can change the column name as per database in [Column] Attribute.
Do not change the property name because it is linked with interface.
Code:
[Column("ModifiedBy")]
public new string ModifiedBy { get; set; }
5. Trashed (Property in model/column in database) or column with same feature
You can change the column name as per database in [Column] Attribute.
Do not change the property name because it is linked with interface.
Code:
[Status, Deleted]
[Column("Trashed")]
public new bool Trashed { get; set; }
6. RowVersion (Property in model/column in database) or column with same feature
You can change the column name as per database in [Column] Attribute.
Do not change the property name because it is linked with interface.
Code:
[Timestamp]
[ConcurrencyCheck]
[RowVersion]
[Column("RowVersion")]
public new byte[] RowVersion { get; set; }
6. Status (Property in model/column in database) or column with same feature
You can change the column name as per database in [Column] Attribute.
Do not change the property name because it is linked with interface.
Code:
[Column("Status")]
public new bool Status { get; set; }
=====================================================================================
Add following attributes to get the data from the linked tables. Find/FindAll functions will automatically add joins in select query.
[LeftJoin]
[InnerJoin]
[RightJoin]
example: for User Model
[Table("Users")]
public class User
{
[Key, Identity]
public int Id { get; set; }
public string ReadOnly => "test"; // because don't have set
public string Name { get; set; }
public int AddressId { get; set; }
[LeftJoin("Cars", "Id", "UserId")] //UserId is property in Cars model
public List<Car> Cars { get; set; }
[LeftJoin("Addresses", "AddressId", "Id")] // Id is Primary key in Address model
public Address Address { get; set; }
[Status, Deleted]
public bool Deleted { get; set; }
[UpdatedAt]
public DateTime? UpdatedAt { get; set; }
}