using MongoDB.Bson; using MongoDB.Driver; using MongoDB.Driver.Core.Configuration; using Npgsql; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SushiBarMongoDB { public static class PostgresToMongo { public static void Convert() { string postgresConnection = "Host=localhost;Username=postgres;Password=shotboll200412;Database=SUBDLab8"; using var psqlConn = new NpgsqlConnection(postgresConnection); psqlConn.Open(); var client = new MongoClient("mongodb://localhost:27017"); var database = client.GetDatabase("lab8SUBD"); var buyers = database.GetCollection("Buyers"); var cooks = database.GetCollection("Cooks"); var menus = database.GetCollection("Menus"); var places = database.GetCollection("Places"); var tasks = database.GetCollection("Tasks"); //Конвертация покупателей using var psqlBuyers = new NpgsqlCommand("SELECT * FROM \"Buyers\"", psqlConn); using var readBuyers = psqlBuyers.ExecuteReader(); while(readBuyers.Read()) { var document = new BsonDocument(); for(int i = 0;i