using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using MongoDB.Bson; using MongoDB.Driver; using MongoDB.Driver.Builders; using MongoDB.Driver.Linq; public partial class _Default : System.Web.UI.Page { MongoCollection collection; MongoDatabase database; string s1; protected void Page_Load(object sender, EventArgs e) { database = new MongoClient("mongodb://avant:avant@127.0.0.1:27017").GetServer().GetDatabase("demo1");//database collection = database.GetCollection<ques>("que"); s1 = Request.QueryString["t1"]; Response.Write("<h1>"); Response.Write(s1); } class ques { public ObjectId id { get; set; } public string question { get; set; } public string category { get; set; } public List <ans> answer { get; set; } public string user { get; set; } } class ans { public ObjectId id { get; set; } public string answer { get; set; } public string score { get; set; } } protected void Button1_Click(object sender, EventArgs e) { collection.Update(Query.EQ("question", " What is an object? "), Update.SetWrapped<ans>("answer", new ans { answer = TextBox1.Text, score = "5" })); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)