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

Support "Named Value Dictionaries" #214

Merged
merged 13 commits into from
Apr 18, 2015
Merged

Support "Named Value Dictionaries" #214

merged 13 commits into from
Apr 18, 2015

Conversation

mfenniak
Copy link
Owner

The long overdue capability to support free-form data objects inside rethinkdb-net without relying on the rethinkdb-net-newtonsoft add-on library. This will also add many dictionary operations to the key capabilities.

  • Support converting Dictionary<string,object> round-trip to RethinkDB.
  • Automatically detect the best object type to deserialize for a given RethinkDB value.
    • numbers -> double or int
    • objects:
      • special case: byte array
      • special case: DateTimeOffset
      • named value collection
    • string
    • bool
    • arrays....
      • string arrays -- all types are string or null gets a string[]
      • number arrays -- all types are int gets in int[], all types are int or null gets an int?[], all types are int or double gets a double[], all types are int or double or null gets a double?[]
      • all types are the same and or null, and the type is a reference type, gets a TReferenceType[]
      • all types are the same and or null, and the type is a value type, gets a TValueType?[]
      • throw an error; unable to find a homogenous array type. In the future, maybe we'd support a heterogeneous type like object[]
  • Dictionary operations:
    • .ContainsKey(...)
    • .ContainsValue(...) No ReQL operation for this (and, why would you want to anyway?)
    • Count property No ReQL operation to find the number of keys in an object.
    • Keys property
    • Values property
    • Item accessors; eg. dictionary[key], for getting.
    • Item accessors; eg. dictionary[key], for setting. Doesn't return a Dictionary type, so can't make it work in a LINQ expression. Created an alternative instead (next point).
    • Extension method to set a dictionary value in an Update query; dict.SetValue(key, value).SetValue(key2, value2)
    • .Add(...) method Returns void, can't use; however, SetValue extension method above does same functional capability.
    • .Remove(...) method No exact match for this in ReQL, but, did implement .Without() to exclude a key from a dictionary.
  • Do useful things with the values of a dictionary; since they're of type object, this might require supporting casts in the expression converter. eg. .Filter(o => (int)o.FreeformProperties["awesome level"] > 10)
  • Update release notes.
  • How hard would it be to support dictionaries other than <string,object> now that most of the above work is done? --> easy; this has been implemented. Dictionary values can now be strongly typed or weakly typed by using System.Object.

@mfenniak mfenniak self-assigned this Apr 17, 2015
mfenniak added a commit that referenced this pull request Apr 18, 2015
Support "Named Value Dictionaries" and dictionary related operations
@mfenniak mfenniak merged commit 3dfde47 into master Apr 18, 2015
@mfenniak mfenniak deleted the named_value_collection branch April 18, 2015 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant