2

I'm using MongoDb C# driver in my application and I need to update a sub-item in my document. I found the way doing something like this:

var query = Query<User>.ElemMatch(_=>_.Item, qb=>qb.EQ(x => x.Valid,false));

var update = Update.Set("Item.$.Valid", true); <-- can I use lambda here?

var result = collection.Update(query, update);

Now I want to ask you: Can I use lambda syntax to remove the fixed string "Item.$.Valid" enabling compile-time check (like Update<Item>.Set(x=>x...)?

Inside driver source code I've found nothing about this!

2
  • It's an interesting question :-) Commented Oct 30, 2014 at 12:21
  • @daniele3004 you can upvote to indicate that Commented Oct 30, 2014 at 12:41

1 Answer 1

2

Not right now. This is the JIRA ticket for it. https://jira.mongodb.org/browse/CSHARP-588

Coming up with a good syntax for this without doubling all the helper methods is difficult. We are completely open to suggestions, so please comment on the JIRA ticket if you have some.

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.