Go to Heavy MongoDB LIST

Source: Internet
Author: User

Using mongodb;using docksample.db;using mongodb.driver;using system;using system.collections.generic;using System.componentmodel;using system.data;using system.drawing;using system.io;using System.Linq;using System.Text; Using system.windows.forms;using weifenluo.winformsui.docking;using mongodb.bson;namespace DockSample{Public        Partial class Form2:dockcontent {public Form2 () {InitializeComponent ();  }//////////////////////workaround of RichTextbox control ' s bug://////////////////////If load file before        The control showed, all the text format is lost//////////////////////re-load the file after it get showed.        private bool M_resettext = true; protected override void OnPaint (PaintEventArgs e)////////////////////{//////////////// Base.        OnPaint (e); if (M_resettext)////////////////////{//////////M_resettext = false; }////////////////////}////////////////////////protected override string Getpersist String ()////////////////////////{//////////////////////////ADD extra information into the persist str        ing for the document/////////////////////////So, it's available when deserialized. Return GetType ().        ToString () + ", 1123," + Text;        }////////////////////private void Menuitem2_click (object sender, System.EventArgs e) {////////////////////MessageBox.Show ("This was to demostrate the menu item has been SUCCESSFU Lly merged into the main form.        Form text= "+ Text");        }////////////////////private void Menuitemchecktest_click (object sender, System.EventArgs e) {////////////////////}////////////////////protected override void OnTextChanged (EventArgs e)////////////////////{////////////////////base.        OnTextChanged (e); private void Button1_Click (object sender, EventArgs e) {UserA u = new            UserA ();            U.cid = 10;            U.name = "test to see";            Writeconcernresult s = mongodbhelper.insertone ("User", u); Label1. Text = s.documentsaffected.tostring () + "------" + s.haslasterrormessage.tostring ();//s.haslasterrormessage=        False both indicates that the operation was successful! private void Button2_Click (object sender, EventArgs e) {imongoquery query = MongoDB.Driver.Bui Lders.           Query.eq ("CID", 9);            UserA u = mongodbhelper.getone<usera> ("user", query); ienumerable<usera> u = mongodbhelper.getall<usera> ("user").            Distinct<usera> (New Modelcomparer ());            UserA u = mongodbhelper.getone<usera> ("User", "555993c18825b905c8879edc"); Label1. Text =U.cid.tostring () + "---" + u.name;            foreach (UserA ua in U) {richtextbox1.appendtext (ua.cid.ToString () + "--" + Ua.name + "\ r \ n"); }} private void Button3_Click (object sender, EventArgs e) {Mongodbhelper.delet                  Eall ("user");        }} public class UserA {public ObjectId ID {get; set;}        public int CID {get; set;}    public string name {get; set;}             } public class Modelcomparer:iequalitycomparer<usera> {public bool Equals (UserA x, UserA y) {        return X.name.toupper () = = Y.name.toupper (); } public int GetHashCode (UserA obj) {return obj.name.ToUpper ().        GetHashCode (); }    }}

  

Go to Heavy MongoDB LIST

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.