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

Implement "Take" method for selecting a range of items from a superset #3

Closed
jeffrymorris opened this issue Oct 10, 2014 · 1 comment

Comments

@jeffrymorris
Copy link
Contributor

No description provided.

@SamFold
Copy link
Contributor

SamFold commented Oct 16, 2014

Working on this

jeffrymorris referenced this issue in brantburnett/Linq2Couchbase Oct 18, 2015
Motivation
----------
Provide a method of controlling the keys for documents using an easy POCO
approach, but with customizability for more advanced use cases.

Modifications
-------------
For the default use case, move from a single KeyAttribute property on the
document to supporting multiple KeyAttribute properties.  Then concatenate
their values together, separated by a "-".  Control their order with
KeyOrderAttribute.

An example use case would be documents whose keys are built as a
combination of the Type property (i.e. "beer") and a unique id such as an
auto-increment or a GUID (i.e. a Number property with the value "1").  By
putting a Key and KeyOrder attribute on each property, the generator will
give it the key "beer-1".

This also works well for simple keys read from a single property.  If you
only place the Key attribute on one property, its value is used directly.

For more advanced use cases, the DocIdGenerator property may be applied to
a document.  This takes a type that implements IDocIdGenerator, which
allows for any kind of custom key building.

Notes
-----
The limitation of this approach is that it assumes that the document ID
generator will always generate the same key the document had when it was
read via LINQ.  The advantage is that it easily supports creating new
documents, since it will generate the new key from the document the same
way for new or existing documents.  This makes designing an object model
with consistent keys easy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants