Skip to content
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

Add instruction for preparing models in .NET SDK readme #741

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion templates/dotnet/README.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,31 @@ dotnet add package {{ spec.title | caseUcfirst }} --version {{ sdk.version }}
{{ sdk.gettingStarted|raw }}
{% endif %}

### Preparing Models for Databases API

For the .NET SDK, we use the `Newtonsoft.Json` library for serialization/deserialization support. The default behavior converts property names from `PascalCase` to `camelCase` on serializing to JSON. In case the names of attributes in your Appwrite collection are not created in `camelCase`, this serializer behavior can cause errors due to mismatches in the names in the serialized JSON and the actual attribute names in your collection.

The way to fix this is to add the `JsonProperty` attribute to the properties in the POCO class you create for your model.

For e.g., if you have two attributes, `name` (`string` type) and `release_date` (`DateTime` type), your POCO class would be created as follows:

```csharp
public class TestModel
{
[JsonProperty("name")]
public string Name { get; set; }

[JsonProperty("release_date")]
public DateTime ReleaseDate { get; set; }
}
```

The `JsonProperty` attribute will ensure that your data object for the Appwrite database is serialized with the correct names.

## Contribution

This library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.

## License

Please see the [{{spec.licenseName}} license]({{spec.licenseURL}}) file for more information.
Please see the [{{spec.licenseName}} license]({{spec.licenseURL}}) file for more information.