-
Notifications
You must be signed in to change notification settings - Fork 58
MapInstantApis fails when key is not named id when using fluent interface [Bug] #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Interesting idea.. let’s get a OR together and add it to the mix
Jeff
… On Aug 20, 2022, at 17:08, Wayne Mather ***@***.***> wrote:
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)));
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
|
Hi, Can you confirm you have an off by 1 error in your message? O => P 😁 |
Doh… yea. iPhone autocorrect isn’t a fan of PR.
Jeff
… On Aug 21, 2022, at 18:04, Wayne Mather ***@***.***> wrote:
Hi,
Can you confirm you have an off by 1 error in your message? O => P 😁
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
I am doing something like the following:
But it means changing Configuration from private to internal so that MapApiExtensions has access to it. Is this going to be a problem? |
Pull request created |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
The text was updated successfully, but these errors were encountered: