question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change the "ID" field to "Id"

See original GitHub issue

This way, when libraries that automatically camelcase the name of the fields (json serialization, graphql model serialization), it will get named “id” rather than “iD”. This is the conventional way of casing Id fields.

Since we are required to inherit from Entity or implement IEntity, this should really follow Microsoft conventions on casing.

This is what I have to do in all of my models just to get behavior that would work automatically if the field were named “Id”.

[Name("results")]
public class OrderResults: Results, IEntity, IModifiedOn {
    [GraphQLName("id"), GraphQLType(typeof(NonNullType<IdType>))]
    [BsonId, BsonRepresentation(BsonType.ObjectId)]
    public string ID { get; set; } = ObjectId.GenerateNewId().ToString();

    public DateTime ModifiedOn { get; set; } = DateTime.Now;
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
dj-nitehawkcommented, Sep 15, 2020

another alternative is for you to fork the source and make your own version of the library with an Id property on IEntity

0reactions
bryanmattesoncommented, Sep 15, 2020

Thank you for the quick response.

Read more comments on GitHub >

github_iconTop Results From Across the Web

change id field to people_id
Hi I am trying to change the id field to people_id and simply display from a route as I am learning trying to...
Read more >
ASP.Net core change field from default id to custom id
I did some research on Ef core and the primary key etc, and it seems that Ef core will use the Id field...
Read more >
How to Edit ID Field?
The ID field (I'm assuming you mean primary key field) should NOT be changing if you delete a record, especially if there are...
Read more >
How to Rename ID Column in SharePoint List?
Go to the List settings page · Pick any column such as “Title”. You'll get the Edit Column page. · Change the Field...
Read more >
Is it possible to update default ID column of a list in ...
It's not possible to update the default ID column of a list in SharePoint online. ID field is an auto-increase column and it's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found