-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIMutableId.cs
More file actions
32 lines (31 loc) · 1.17 KB
/
IMutableId.cs
File metadata and controls
32 lines (31 loc) · 1.17 KB
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
namespace Light.SharedCore.Entities;
/// <summary>
/// <para>
/// Represents the abstraction of an entity whose ID
/// can be set after it has been fully initialized.
/// </para>
/// <para>
/// BE CAREFUL: you must not change the ID of your Entity when it should already be immutable.
/// This is e.g. the case when the ID is used as a key within a dictionary.
/// </para>
/// </summary>
/// <typeparam name="T">The type of the ID.</typeparam>
public interface IMutableId<in T>
{
/// <summary>
/// <para>
/// Sets the Id after the entity is already initialized.
/// </para>
/// <para>
/// BE CAREFUL: you must not call this method when the ID of your Entity should already be immutable.
/// This is e.g. the case when the ID is used as a key within a dictionary.
/// </para>
/// <para>
/// However, when inserting an entity into a database, the database will usually generate the ID
/// of the entity at this point in time. Updating the ID after the insert is OK and
/// this is the usual scenario where this method should be called.
/// </para>
/// </summary>
/// <param name="id">The new ID for the entity.</param>
void SetId(T id);
}