mongodb - Deprecated Methods in C# Mongo Driver -


in latest version of c# driver 10gen seems have shifted more typed version of .find() method. seems mongocollection.find(imongoquery) deprecated, replaced mongocollection.findas(type, imongoquery). fine (although don't see deprecation mentioned anywhere in documentation); however, mongocursor no longer contains .tolist() method. attempting work around these missing methods tried use mongocursor.ienumerablegetenumerator(), ide complains not valid method.

to simplify question below code segment of doing, how accomplished new driver?

var queryresult = collection.find(query.and(largequerylist[i])).tolist(); try { result = queryresult.sum(w => w[valuefield].todouble()); } 

i'm not sure when last updated driver, doesn't method has been there in quite while mongocollection class. present on generic mongocollection<type> class. driver needs know type deserialize into, you'll need indicate document type. through generic bsondocument:

mongocollection<bsondocument> 

or, if have specific type, can substitute there.

if don't want use generic version, you'll need use findas or 1 of equivalent methods indicate type.

once that, you'll see tolist should available.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -