Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Added support for persisting value objects in shared collections.#4

Merged
iscottb122 merged 7 commits intomasterfrom
value-objects
Sep 19, 2018
Merged

Added support for persisting value objects in shared collections.#4
iscottb122 merged 7 commits intomasterfrom
value-objects

Conversation

@iscottb122
Copy link
Copy Markdown
Contributor

No description provided.

{
if (documentCollection.PartitionKey.Paths.Any())
{
throw new NotSupportedException("Partitioned collections not supported.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the error message not be: "Partitioned collections are not supported"?

{
string valueObjectType = ValueObjectDocument<TValueObject>.GetDocumentType();

ValueObjectDocument<TValueObject> document =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this is the same as for the Create method, I think we could have a private Find method that finds the ValueObjectDocument by the TValueObject.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could also extract:

string valueObjectType = ValueObjectDocument<TValueObject>.GetDocumentType();
ValueObjectDocument<TValueObject> document =
    _documentClient.CreateDocumentQuery<ValueObjectDocument<TValueObject>>(GetUri())
                   .Where(x => x.Type == valueObjectType)
                   .AsEnumerable()

into a private method called something like CreateValueObjectDocumentQuery

}
}

public sealed class Type : EntityDocumentTests
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should inherit from ValueObjectDocumentTests rather than EntityDocumentTests.

}

[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have to be mutable for it to work with DocumentDB?

@iscottb122 iscottb122 merged commit c5dac7d into master Sep 19, 2018
@iscottb122 iscottb122 deleted the value-objects branch September 19, 2018 13:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants