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.

Ability to change the serialized property name

See original GitHub issue

We should have the ability to change the serialized property name when serializing and saving to mongodb; similar to the the way we are able to change the name of the class object. for example:

[Name("employee")]
public class EmployeeEntity : Entity {
     [Name("fname")]
     public string FirstName { get; set; }

     [Name("lname")]
     public string LastName { get; set; }
}

Should be serialized to:

{ 
    "_id": {  "$oid": "60b36d297e3d155fe85a4b84" },
    "fname": "aaa",
    "lname": "bbb"
}

Or by default, when serializing to json, all properties are converted to lowercase

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
paolobrionescommented, May 30, 2021

i only really use BsonElementAttribute, but the naming is so off as compared to how the naming goes in mongodb-entities that i just had to request it

1reaction
dj-nitehawkcommented, May 30, 2021

yeah i could add an attribute called [Field("FieldName")]. sounds good? because we can’t use the same [Name(...)] attribute for both purposes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing the name of the SerializedProperty (breaks ...
This is quite an issue if already having a bunch of values serialized (saved with project) with another name.
Read more >
c# - How can I change property names when serializing ...
json file. I would like to change the property names to be something different (say, change 'foo' to 'bar'). In the Json.net documentation, ......
Read more >
SerializedProperty.name - Scripting API
SerializedProperty.name. Leave feedback. Suggest a change ... Submit suggestion. Cancel. public string name;. Description. Name of the property. (Read Only) ...
Read more >
Scripting API: SerializedProperty
SerializedProperty is primarily used to read or change the value of a property. It can also iterate through the properties of an object...
Read more >
How to customize property names and values with System. ...
To set the name of individual properties, use the [JsonPropertyName] attribute. Here's an example type to serialize and resulting JSON:.
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