Ejemplo n.º 1
0
        public override string GetDataProviderFieldType(FieldType fieldType)
        {
            var mySqlType = typeConverter.GetDataProviderFieldType(fieldType);

            return(MySqlDbTypeConverter.GetMySqlDataTypeStringValue(mySqlType));
        }
Ejemplo n.º 2
0
        //public override void InsertRecords(string tableName, IEnumerable<Record> records)
        //{
        //    const string INSERT_INTO_FORMAT = "INSERT INTO {0}({1}) VALUES({2})";
        //    string fieldNames = records.ElementAt(0).Fields
        //        .Select(f => f.Name)
        //        .OrderBy(f => f)
        //        .Join("`,`").Prepend("`").Append("`");

        //    using (MySqlConnection connection = new MySqlConnection(ConnectionDetails.ConnectionString))
        //    {
        //        connection.Open();
        //        using (MySqlTransaction transaction = connection.BeginTransaction())
        //        {
        //            using (MySqlCommand command = connection.CreateCommand())
        //            {
        //                command.Transaction = transaction;
        //                //command.CommandText = "SET NAMES UTF8; SET CHARACTER SET UTF8;";
        //                //command.ExecuteNonQuery();

        //                StringBuilder sbValues = null;
        //                records.ForEach(record =>
        //                {
        //                    sbValues = new StringBuilder(50);
        //                    record.Fields.OrderBy(f => f.Name).ForEach(field =>
        //                    {
        //                        if (field.IsNumeric)
        //                        {
        //                            sbValues.Append(field.Value);
        //                        }
        //                        else if (field.Type == FieldType.DateTime)
        //                        {
        //                            sbValues.Append(field.GetValue<DateTime>().ToISO8601DateString().AddSingleQuotes());
        //                        }
        //                        else
        //                        {
        //                            sbValues.Append("'", field.Value.ToString().Replace("'", "''"), "'");
        //                        }
        //                        sbValues.Append(",");
        //                    });
        //                    sbValues.Length -= 1; // Remove last comma ","

        //                    command.CommandText = string.Format(INSERT_INTO_FORMAT, tableName, fieldNames, sbValues.ToString());
        //                    command.ExecuteNonQuery();
        //                });
        //            }
        //            transaction.Commit();
        //        }
        //        connection.Close();
        //    }
        //}

        public override FieldType GetDataMigratorFieldType(string providerFieldType)
        {
            var mySqlType = MySqlDbTypeConverter.GetMySqlDataType(providerFieldType);

            return(typeConverter.GetDataMigratorFieldType(mySqlType));
        }