Skip to content

Instantly share code, notes, and snippets.

@felipeleusin
Created March 24, 2011 15:04
Show Gist options
  • Save felipeleusin/885201 to your computer and use it in GitHub Desktop.
Save felipeleusin/885201 to your computer and use it in GitHub Desktop.
DenormalizedStoreListener
var refs = from p in entityInstance.GetType().GetProperties()
where
p.PropertyType.IsGenericType &&
p.PropertyType.GetGenericTypeDefinition() == typeof(DenormalizedReference<>)
select p;
var result = new JArray();
foreach (var p in refs)
{
dynamic dynVal = p.GetValue(entityInstance, null);
if (dynVal.Id != null && dynVal.Name != null)
{
result.Add(new JObject(new JProperty("Key", dynVal.Id), new JProperty("Path", p.Name)));
}
}
if (result.Count <= 0)
{
return;
}
metadata.Remove(DenormalizedTracking);
metadata[DenormalizedTracking] = result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment