MongoDB 3.4 version, C # driver 2.4 operation

Source: Internet
Author: User
Tags mongodb gui

private static string _connstr = "mongodb://127.0.0.1:27017";        private static string _dbname = "Test";        Const string CollectionName = "Sun";


  private static Imongodatabase db        {            get            {                var url = new Mongourl (_CONNSTR);                var client = new Mongoclient (URL);                Return client. Getdatabase (_dbname);            }        }



            Database connection string #region//Get Table object imongocollection<video> TB = db.            Getcollection<video> (CollectionName); Delete the current table TB first.            Database.dropcollection (CollectionName); Test data---------------------------------var videos = new List<video> {new Video { Title= "The Perfect Developer", category= "SciFi", minutes=118}, new Video {title= "L OST in Frankfurt am Main ", category=" horror ", minutes=122}, new Video {title=" the            Infinite standup ", category=" horror ", minutes=341}}; Test data---------------------------------//Insert TB.            Insertmany (VIDEOS); Query var all = tb. Find (x = x.title! = string. Empty).            ToList (); Packet query var groupby = tb. Aggregate (). Group (x = x.category,g = new {Name = G.key, Count = G.count (), totalminutes = g.sum (x = = x.minutes)}).                      ToList (); Updated//updating title with "The Perfect developer" video ' s ' title ' and ' minute ' TB. Findoneandupdate (x = X.title = = "The Perfect Developer", Builders<video>. Update.set (x = x.title, "A Perfect Developer [Updated]").                                          Addtoset (x = x.comments, "Good video!") .            Addtoset (x = x.comments, "not bad")); all = TB. Find (x = x.title! = string. Empty).                       ToList (); Remove TB.            Deleteone (x = x.minutes = = 122); all = TB. Find (x = x.title! = string. Empty).                       ToList (); #endregion

.



It is recommended to use a 2 MongoDB GUI

1, Mongodbcompass


2, Robomongo




64-bit MongoDB installation tools and GUI tools under Windows

Http://pan.baidu.com/s/1c2gqJGO


. NET MongoDB Drivers

Http://pan.baidu.com/s/1eRZ1eNo

MongoDB 3.4 version, C # driver 2.4 operation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.