1

Here's what my serialized c# object looks like (simplified for the example, of course):

public class SerializedObject
{
    public string _id { get; set; }

    [BsonDictionaryOptions(DictionaryRepresentation.Document)]
    [StoreAs("D")]
    public Dictionary<string, Metric> Daily { get; set; }
}

the Metric object:

public class Metric
{
    [StoreAs("CT")]
    public int Count { get; set; }
}

What I'm trying to do:

var update = Update<SerializedObject>.Inc(x => x.Daily["2"].Count, 1);

The error thrown, a NotSupportedException:

Unable to determine the serialization information for the expression: (SerializedObject x) => x.Daily.get_Item("2").Count.

Is it as the name of the exception says, something not yet implemented in the 10gen's MongoDB C# driver? Is there a way of doing something like this rather than doing a untyped Update on the actual "stringified" name of the field? (which would be:

Update.Inc("D.2.CT", 1);

Thanks.

5
  • Can you try cutting the example down to see if, for example, you'd get the problem doing: var update = Update<SerializedObject>.Inc(x => x.Daily["2"], new Metric()); This will help determine if it's the use of the Metric or the property underneath it. Commented Feb 26, 2014 at 12:43
  • That example doesn't work, at least not with Update.Inc given that x.Daily["2"] cannot be converted to int/double/long. I tried with a Set instead of Inc and your suggestion, doesnt' work either, same error. Commented Feb 26, 2014 at 12:50
  • Does it require a value type, rather than a reference type (or does it have to be even more basic)? Could you try changing the Metric class into a struct? Commented Feb 26, 2014 at 12:56
  • I've tried a few things out of your suggestions, no matter the type of Daily, the type of Metric, the problem still narrows down to (SerializedObject x) => x.Daily.get_Item("2") Commented Feb 26, 2014 at 13:10
  • 1
    If you've got a good decompiler, like dotPeek from JetBrains, which is free (I think), then you could easily go to the Mongo source for Update or Inc and look for where the exception is being thrown and the real reason why. It might just be as you said that it isn't implemented. Commented Feb 26, 2014 at 13:12

1 Answer 1

2

Got my answer from the mongodb's google group:

craiggwilson: Yep, this is a unimplemented feature. See the feature request here: https://jira.mongodb.org/browse/CSHARP-917.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.