how to group by and count using Mongodb c# driver

3,249 views
Skip to first unread message

la ke

unread,
Dec 19, 2014, 8:34:57 AM12/19/14
to mongod...@googlegroups.com
i want to  "select col1 ,count(*) from table1 group by col1" in mongodb. how can i write?

i try to write this,but it's fail.

var query 
    = from e in collection.AsQueryable<table1>()
       group e by e.col1 into g
       select new {g.Key,g.Count()}


the driver is not suported the "group by ",how can i do,please
        

s.molinari

unread,
Dec 19, 2014, 10:54:12 PM12/19/14
to mongod...@googlegroups.com
I found this and thought it might help.


It is around 2 years old, but I think enough still holds true.

Scott

la ke

unread,
Dec 20, 2014, 9:26:07 AM12/20/14
to mongod...@googlegroups.com
thank you very much,i think it will help me.i will try it in monday

在 2014年12月20日星期六UTC+8上午11时54分12秒,s.molinari写道:

tom...@gmail.com

unread,
Dec 20, 2014, 1:15:58 PM12/20/14
to mongod...@googlegroups.com
Check out MongoLinqPlusPlus, a Linq provider for MongoDB's aggregation framework: https://bitbucket.org/tomAdomic/mongolinqplusplus

It was written to support exactly this kind of query.
Reply all
Reply to author
Forward
0 new messages