Skip to content

Instantly share code, notes, and snippets.

@TsuyoshiUshio
Last active June 13, 2017 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TsuyoshiUshio/56267fd1428760057bfadb118abc7a1e to your computer and use it in GitHub Desktop.
Save TsuyoshiUshio/56267fd1428760057bfadb118abc7a1e to your computer and use it in GitHub Desktop.
Visual Studio Hack
using CsvHelper;
using MongoDB.Bson;
using MongoDB.Driver;
using System;
using System.IO;
using System.Text;
using System.Threading;
namespace CSVTest
{
class Program
{
static void Main(string[] args)
{
Console.Write(System.IO.Directory.GetCurrentDirectory());
using (FileStream fs = new FileStream(args[0], FileMode.Open))
{
using (StreamReader sr = new StreamReader(fs))
{
var csv = new CsvReader(sr);
while(csv.Read())
{
var id = csv.GetField<int>(0);
var name = csv.GetField<string>(1);
Console.WriteLine("\nid: {0}, name: {1}", id, name);
}
}
}
var client = new MongoClient("mongodb://removethis:JyFUWGu78lEVANZuucNK7H9HNd85dJAeXw67AkWSHoDVjtQBVYP9NVJUEIw19WPvRnDrSkfk2yxs0JmDrA1YOQ==@removethis.documents.azure.com:10255/?ssl=true&replicaSet=globaldb");
var db = client.GetDatabase("sampledb");
var collection = db.GetCollection<BsonDocument>("sample");
var document = collection.Find(new BsonDocument()).FirstOrDefault();
Console.WriteLine(document.ToString());
Console.WriteLine("Hello World!");
Thread.Sleep(20000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment