Closed
Description
When using the fluent interface and not marking your keys with the [Key] annotation and those keys are not named "id" then the _IdLookup dictionary will not be filled with the keys for the entity.
This is due to MapApiExtensions having id hard coded into it. I wonder if it would be easy to add a configuration option to define how the property is matched? For example {ClassName}Id or {ClassName}_Id
I did a quick proof of concept by adding the following code in line 26 of MapApiExtensions:
var theType = typeof(C);
var keyName = $"{theType.Name}Id";
var idProp = theType.GetProperty("id", BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance) ??
theType.GetProperty(keyName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance) ??
theType.GetProperties().FirstOrDefault(p => p.CustomAttributes.Any(a => a.AttributeType == typeof(KeyAttribute)));
Metadata
Metadata
Assignees
Labels
No labels