Skip to content

Instantly share code, notes, and snippets.

@meriturva
Last active August 22, 2019 14:24
Show Gist options
  • Save meriturva/053c1cb42564ff288173c175a47ac5b3 to your computer and use it in GitHub Desktop.
Save meriturva/053c1cb42564ff288173c175a47ac5b3 to your computer and use it in GitHub Desktop.
Repository.cs
protected virtual object[] GetKeysValues(TEntity entity)
{
var entry = Context.Entry(entity);
return entry.Metadata.FindPrimaryKey()
.Properties
.Select(p => entry.Property(p.Name).CurrentValue)
.ToArray();
}
public string GenerateEntityId(TEntity entity)
{
return String.Join('$', this.GetKeysValues(entity));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment