Skip to content

Instantly share code, notes, and snippets.

@Kayli
Created March 14, 2013 20:57
Show Gist options
  • Save Kayli/5165207 to your computer and use it in GitHub Desktop.
Save Kayli/5165207 to your computer and use it in GitHub Desktop.
Events repository example
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