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 : using System.Data.Linq.Mapping;
11 : using System.Runtime.Serialization;
12 : using Cqrs.Domain;
13 : using Cqrs.Messages;
14 :
15 : namespace Cqrs.Events
16 : {
17 : /// <summary>
18 : /// Captures all the data relevant to an <see cref="IEvent{TAuthenticationToken}"/> for an <see cref="IEventStore{TAuthenticationToken}"/> to persist.
19 : /// </summary>
20 : [Serializable]
21 : [DataContract]
22 : [Table(Name = "EventStore")]
23 : public class EventData
24 1 : {
25 : /// <summary>
26 : /// The data/content of the <see cref="IEvent{TAuthenticationToken}"/>.
27 : /// </summary>
28 : [DataMember]
29 : [Column(CanBeNull = false, DbType = "text NOT NULL")]
30 : public object Data { get; set; }
31 :
32 : /// <summary>
33 : /// The identifier of the <see cref="IEvent{TAuthenticationToken}"/>.
34 : /// </summary>
35 : [DataMember]
36 : [Column(IsPrimaryKey = true)]
37 : public Guid EventId { get; set; }
38 :
39 : /// <summary>
40 : /// The <see cref="Type"/> of the <see cref="IEvent{TAuthenticationToken}"/>
41 : /// </summary>
42 : [DataMember]
43 : [Column(CanBeNull = false)]
44 : public string EventType { get; set; }
45 :
46 : /// <summary>
47 : /// The globally identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/> , meaning it also includes <see cref="Type"/> information.
48 : /// </summary>
49 : [DataMember]
50 : [Column(CanBeNull = false)]
51 : public string AggregateId { get; set; }
52 :
53 : /// <summary>
54 : /// The identifier of the <see cref="IAggregateRoot{TAuthenticationToken}"/>.
55 : /// </summary>
56 : [DataMember]
57 : [Column(CanBeNull = false)]
58 : public Guid AggregateRsn { get; set; }
59 :
60 : /// <summary>
61 : /// The new version number the targeted <see cref="IAggregateRoot{TAuthenticationToken}"/> or <see cref="ISaga{TAuthenticationToken}"/> that raised this.
62 : /// </summary>
63 : [DataMember]
64 : [Column(CanBeNull = false)]
65 : public long Version { get; set; }
66 :
67 :
68 : /// <summary>
69 : /// The date and time the event was raised or published.
70 : /// </summary>
71 : [DataMember]
72 : [Column(CanBeNull = false)]
73 : public DateTime Timestamp { get; set; }
74 :
75 : /// <summary>
76 : /// 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.
77 : /// </summary>
78 : [DataMember]
79 : [Column(CanBeNull = false)]
80 : public Guid CorrelationId { get; set; }
81 :
82 : /// <summary>
83 : /// Instantiates a new instance of <see cref="EventData"/>.
84 : /// </summary>
85 1 : public EventData()
86 : {
87 : Timestamp = DateTime.UtcNow;
88 : }
89 : }
90 : }
|