[英]How to log results to console with MongoDB 3.0 c# driver
I am writing the simple c# console program to connect mongodb db instance and get the value from the mongodb and need to display console window. 我正在编写简单的c#控制台程序以连接mongodb数据库实例并从mongodb获取值,并且需要显示控制台窗口。 I am using mongodb version 3.0.
我正在使用mongodb 3.0版。
I am getting date but not able display console. 我正在获取日期,但无法显示控制台。 I am getting struck with syntax.
我对语法感到震惊。
Any one please help me, I have shared my sample code below. 任何人都可以帮助我,我在下面共享了我的示例代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MongoDB;
using MongoDB.Driver;
using MongoDB.Bson;
using MongoDB.Driver.Linq;
namespace MongoCHash
{
class Program
{
static void Main(string[] args)
{
var mongod = new MongoClient();
var db=mongod.GetDatabase("MyDB");
var movies = db.GetCollection<Movie>("movie");
}
}
public class Movie
{
public ObjectId Id { get; set; }
public string name { get; set; }
}
}
You have got a Movie object collection you need to iterate over the collection and the do a Console.Log() of what ever property of the movie object you want including date. 您已经有了一个Movie对象集合,您需要遍历该集合,并对想要包含日期的电影对象的ever属性进行Console.Log()处理。 If you want I can post an example.
如果您愿意,我可以举个例子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.