Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : #if NET40
11 : using System.Data.Linq.Mapping;
12 : #endif
13 : using System.Runtime.Serialization;
14 : using Cqrs.Domain;
15 : using Cqrs.Messages;
16 :
17 : namespace Cqrs.Events
18 : {
19 : /// <summary>
20 : /// Captures all the data relevant to an <see cref="IEvent{TAuthenticationToken}"/> for an <see cref="IEventStore{TAuthenticationToken}"/> to persist.
21 : /// </summary>
22 : [Serializable]
23 : [DataContract]
24 : #if NET40
25 : [Table(Name = "EventStore")]
26 : #endif
27 : public class EventData
28 1 : {
29 : /// <summary>
30 : /// The data/content of the <see cref="IEvent{TAuthenticationToken}"/>.
31 : /// </summary>
32 : [DataMember]
33 : #if NET40
34 : [Column(CanBeNull = false, DbType = "text NOT NULL")]
35 : #endif
36 : public object Data { get; set; }
37 :
38 : /// <summary>
39 : /// The identifier of the <see cref="IEvent{TAuthenticationToken}"/>.
40 : /// </summary>
41 : [DataMember]
42 : #if NET40
43 : [Column(IsPrimaryKey = true)]
44 : #endif
45 : public Guid EventId { get; set; }
46 :
47 : /// <summary>
48 : /// The <see cref="Type"/> of the <see cref="IEvent{TAuthenticationToken}"/>
49 : /// </summary>
50 : [DataMember]
51 : #if NET40
52 : [Column(CanBeNull = false)]
53 : #endif
54 : public string EventType { get; set; }
55 :
56 : /// <summary>
57 : /// The globally identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/> , meaning it also includes <see cref="Type"/> information.
58 : /// </summary>
59 : [DataMember]
60 : #if NET40
61 : [Column(CanBeNull = false)]
62 : #endif
63 : public string AggregateId { get; set; }
64 :
65 : /// <summary>
66 : /// The identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/>.
67 : /// </summary>
68 : [DataMember]
69 : #if NET40
70 : [Column(CanBeNull = false)]
71 : #endif
72 : public Guid AggregateRsn { get; set; }
73 :
74 : /// <summary>
75 : /// The new version number the targeted <see cref="IAggregateRoot{TAuthenticationToken}"/> or <see cref="ISaga{TAuthenticationToken}"/> that raised this.
76 : /// </summary>
77 : [DataMember]
78 : #if NET40
79 : [Column(CanBeNull = false)]
80 : #endif
81 : public long Version { get; set; }
82 :
83 :
84 : /// <summary>
85 : /// The date and time the event was raised or published.
86 : /// </summary>
87 : [DataMember]
88 : #if NET40
89 : [Column(CanBeNull = false)]
90 : #endif
91 : public DateTime Timestamp { get; set; }
92 :
93 : /// <summary>
94 : /// An identifier used to group together several <see cref="IMessage"/>. Any <see cref="IMessage"/> with the same <see cref="CorrelationId"/> were triggered by the same initiating request.
95 : /// </summary>
96 : [DataMember]
97 : #if NET40
98 : [Column(CanBeNull = false)]
99 : #endif
100 : public Guid CorrelationId { get; set; }
101 :
102 : /// <summary>
103 : /// Instantiates a new instance of <see cref="EventData"/>.
104 : /// </summary>
105 1 : public EventData()
106 : {
107 : Timestamp = DateTime.UtcNow;
108 : }
109 : }
110 : }
|