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); } }
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); }