コード例 #1
0
        public void MigrateEncrypyion()
        {
            //get all records from mongo
            var mongoencriptions = mongo.LoadRecords <EncriptionModel>("encryptiontype");

            List <EncriptionType> encriptions = new List <EncriptionType>(mongoencriptions.Count);

            //adding companies to sql list
            foreach (var encription in mongoencriptions)
            {
                var encr = new EncriptionType {
                    EncryptionName = encription.Name
                };
                encriptions.Add(encr);
            }

            foreach (var encript in encriptions)
            {
                dao.CreateEncryption(encript.EncryptionName);
            }
        }
コード例 #2
0
ファイル: MYSQlDao.cs プロジェクト: ssenchh1/NoSQL_lab
        public EncriptionType GetEncriptionByName(string encryption)
        {
            EncriptionType encryptionType = null;
            string         sqlexpression  = String.Format(@"SELECT * FROM encryptiontype WHERE EncryptionName = ""{0}""", encryption);

            using (var connection = Connection.GetInstance().GetConnection())
            {
                connection.Open();
                MySqlCommand command = new MySqlCommand(sqlexpression, connection);
                var          reader  = command.ExecuteReader();
                if (reader.HasRows)
                {
                    Console.WriteLine($"{reader.GetName(0)}\t{reader.GetName(1)}");
                    while (reader.Read())
                    {
                        encryptionType = new EncriptionType((int)reader.GetValue(0), (string)reader.GetValue(1));
                    }
                }
                reader.Close();
            }
            return(encryptionType);
        }