Created
March 14, 2013 20:57
-
-
Save Kayli/5165207 to your computer and use it in GitHub Desktop.
Events repository example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Repository : DbContextFixed | |
{ | |
public Event2 AddEvent(object data) | |
{ | |
return AddEvent(ApplicationStreamId, data); | |
} | |
public Event2 AddEvent(Guid streamId, object data) | |
{ | |
var e = new Event2 { | |
Created = DateTime.Now, | |
Guid = Guid.NewGuid(), | |
StreamId = streamId, | |
DataType = data.GetType().Name, | |
Data = JsonConvert.SerializeObject(data, new JsonSerializerSettings { | |
NullValueHandling = NullValueHandling.Ignore | |
}) | |
}; | |
Events2.Add(e); | |
return e; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment