{"id":1833,"date":"2013-01-26T11:04:46","date_gmt":"2013-01-26T17:04:46","guid":{"rendered":"http:\/\/www.wiredprairie.us\/blog\/?p=1833"},"modified":"2013-01-26T11:05:53","modified_gmt":"2013-01-26T17:05:53","slug":"how-to-view-the-mongodb-query-when-using-the-c-linq-provider","status":"publish","type":"post","link":"https:\/\/www.wiredprairie.us\/blog\/index.php\/archives\/1833","title":{"rendered":"How to view the MongoDB Query when using the C# LINQ Provider"},"content":{"rendered":"

If you\u2019re using the Official MongoDB C# Driver<\/a> from 10gen, you may want to occasionally verify that the generated query matches your LINQ query (or at least that it\u2019s building something efficient). <\/p>\n

Take for example this query:<\/p>\n

var query = \n    (from r in<\/span> DataLayer.Database.GetCollection<Research>().AsQueryable<Research>()\n        where<\/span> !r.Deleted\n        select new<\/span>\n        {\n            Id = r.Id,\n            Title = r.Title,\n            Created = r.Created\n        }).Skip(PageSize * page).Take(PageSize);\n\nquery.DebugWriteMongoQueryText();<\/pre>\n