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

Provide an overload of PostDocumentAsync that allows specifying a different type for new document #304

Closed
DiscoPYF opened this issue Nov 13, 2020 · 0 comments · Fixed by #305
Labels
enhancement New feature or request

Comments

@DiscoPYF
Copy link
Collaborator

DiscoPYF commented Nov 13, 2020

I have a use case where I would like to be able to provide a different type for the newly returned document.

Given existing classes MyModel and MyModelNew containing only a subset of properties from MyModel. I would like to be able to call PostDocumentAsync to post a MyModelNew but return a MyModel. We support this with PatchDocumentAsync.

Using ignore null values values isn't an option because there are null values I would like to post. I could use serialization attributes but provide a new method supporting this use case would be much simpler.

I propose to add PostDocumentAsync<T, U> where T is the type to post and U the type to return in PostDocumentResponse.New, when PostDocumentsQuery.ReturnNew is specified.

Example of use:

var response = await client.PostDocumentAsync<MyModelNew, MyModel>(
    "MyClxName",
    instanceOfMyModelNew,
    new PostDocumentsQuery()
    {
        ReturnNew = true
    });

MyModel fullModel = response.New;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant