public void TestORM() { Console.WriteLine("ORM test start!"); String mysqlStr = "Database=paipaiyuan;Data Source=127.0.0.1;User Id=root;Password=123456;pooling=false;CharSet=utf8;port=3306"; var provider = new MySQLProvider(mysqlStr); using (var session = new DbSession(provider)) { var video = new ppy_video() { Url = "15555555", State = 2, Orderid = 5, Uploadtime = 1453446120 }; session.InsertTransaction(video); session.SubmitChanges(); var query = session.CreateQuery <ppy_video> (); var list = query.Where(v => v.Id <= 215).ToList(); foreach (ppy_video q in list) { Console.WriteLine(q.Url); } } Assert.AreEqual(1, 1); }
public static void Init(TestContext context) { MySQLProvider provider = new MySQLProvider(MySQLHelper.CreateConnectionString("localhost", "kelvin", "testing", "LRTesting")); TestObject.SetProvider(provider, true); TestObject.NewRandom().Insert(); TestObject.NewRandom().Insert(); }
public static Tuple <bool, string> getConnectionStateByConfigurationValues() { return(MySQLProvider.testConnection( ConfigurationProvider.loadConfigurationValue(ConfigurationProvider.mySql_host), ConfigurationProvider.loadConfigurationValue(ConfigurationProvider.mySql_username), ConfigurationProvider.loadConfigurationValue(ConfigurationProvider.mySql_password), ConfigurationProvider.loadConfigurationValue(ConfigurationProvider.mySql_database), Convert.ToInt32(ConfigurationProvider.loadConfigurationValue(ConfigurationProvider.mySql_port)) )); }
public DatabaseFixture() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); var configuration = builder.Build(); employeesDb_provider = new MySQLProvider <employeesDb>(configuration.GetConnectionString("Employees")); information_schema_provider = new MySQLProvider <information_schema>(configuration.GetConnectionString("information_schema")); }
private static void DatabaseFixture() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); var configuration = builder.Build(); var connectionString = configuration.GetConnectionString("information_schema"); DatabaseProvider = new MySQLProvider <information_schema>(connectionString); }
internal static Database GetNewDatabaseProvider(ConnectionStringSettings connectionConfig) { Database provider = SqlServerProvider.GetNewOnMatch(connectionConfig); provider = provider ?? SqlCeProvider.GetNewOnMatch(connectionConfig); provider = provider ?? MySQLProvider.GetNewOnMatch(connectionConfig); if (provider == null) { throw new Exception(string.Format("Found no DatabaseProvider matching \"{0}\"", connectionConfig.ProviderName)); } return(provider); }
public void Execute(string dbname, string namespaceName, string path, MySQLProvider <information_schema> databaseProvider) { var database = MetadataFromSqlFactory.ParseDatabase(dbname, databaseProvider.Read()); Console.WriteLine($"Database: {dbname}"); Console.WriteLine($"Table count: {database.Tables.Count}"); Console.WriteLine($"Writing models to: {path}"); foreach (var file in FileFactory.CreateModelFiles(database, namespaceName)) { var filepath = $"{path}{Path.DirectorySeparatorChar}{file.path}"; Console.WriteLine($"Writing {filepath}"); if (!File.Exists(filepath)) { Directory.CreateDirectory(Path.GetDirectoryName(filepath)); } File.WriteAllText(filepath, file.contents, Encoding.GetEncoding("iso-8859-1")); } }
private void btnTestConnection_Click(object sender, EventArgs e) { var connectionStatus = MySQLProvider.testConnection( edtHost.Text, edtUsername.Text, edtPassword.Text, edtDatabase.Text, Convert.ToInt32(edtPort.Text) ); if (connectionStatus.Item1 == true) { MessageBox.Show( "Die Verbindung zur Datenbank wurde erfolgreich hergestellt!", "Verbindung hergestellt", MessageBoxButtons.OK, MessageBoxIcon.Information ); this.connectionSuccessful = true; } else { MessageBox.Show( "Die Verbindung zur Datenbank konnte nicht hergestellt werden!\n" + "\n" + "Fehler:\n" + connectionStatus.Item2, "Verbindung fehlgeschlagen", MessageBoxButtons.OK, MessageBoxIcon.Error ); this.connectionSuccessful = false; } }
public PersistenceProviderContainer(IConfiguration config) { Provider = new MySQLProvider(config.GetConnectionString("DefaultConnection")); }
public PersistenceProviderContainer() { var connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; _provider = new MySQLProvider(connectionString); }
static void Main(string[] args) { Console.WriteLine("Worm xml schema generator. v0.3 2007"); if (args.Length == 0) { ShowUsage(); return; } CommandLine.Utility.Arguments param = new CommandLine.Utility.Arguments(args); string server = null; if (!param.TryGetParam("S", out server)) { server = "(local)"; } string dbName = null; if (!param.TryGetParam("D", out dbName)) { if (!File.Exists(server)) { Console.WriteLine("Database is not specified or file {0} not found", server); ShowUsage(); return; } } string e; string user = null; string psw = null; if (!param.TryGetParam("E", out e)) { e = "false"; bool showUser = true; if (!param.TryGetParam("U", out user)) { Console.Write("User: "******"P", out psw)) { if (showUser) { Console.WriteLine("User: "******"Password: "******"schemas", out schemas); string namelike = null; param.TryGetParam("name", out namelike); string file = null; if (!param.TryGetParam("O", out file)) { file = dbName + ".xml"; } string merge = null; if (!param.TryGetParam("F", out merge)) { merge = "merge"; } switch (merge) { case "merge": case "error": //do nothing break; default: Console.WriteLine("Invalid \"Existing file behavior\" parameter."); ShowUsage(); return; } string drop = null; if (!param.TryGetParam("R", out drop)) { drop = "false"; } bool dr = bool.Parse(drop); string namesp = dbName; param.TryGetParam("N", out namesp); string u = "true"; if (!param.TryGetParam("Y", out u)) { u = "false"; } bool unify = bool.Parse(u); string hi = "true"; if (!param.TryGetParam("H", out hi)) { hi = "false"; } bool hie = bool.Parse(hi); string tr = "true"; if (!param.TryGetParam("T", out tr)) { tr = "false"; } bool transform = bool.Parse(tr); string es = "true"; if (!param.TryGetParam("ES", out es)) { es = "false"; } bool escapeTables = bool.Parse(es); string ec = "true"; if (!param.TryGetParam("EC", out ec)) { ec = "false"; } bool escapeColumns = bool.Parse(ec); string cn = "true"; if (!param.TryGetParam("CN", out cn)) { cn = "false"; } bool capitalize = bool.Parse(cn); string ss = "false"; if (!param.TryGetParam("SS", out ss)) { ss = "false"; } bool showStatement = bool.Parse(ss); string v = "1"; if (!param.TryGetParam("V", out v)) { v = "1"; } DatabaseProvider dp = null; string m = null; if (!param.TryGetParam("M", out m)) { m = "msft"; } switch (m) { case "msft": case "mssql": if (i) { dp = new MSSQLProvider(server, dbName); } else { dp = new MSSQLProvider(server, dbName, user, psw); } break; case "sqlce": dp = new SQLCEProvider(server, psw); break; case "mysql": if (i) { dp = new MySQLProvider(server, dbName); } else { dp = new MySQLProvider(server, dbName, user, psw); } break; default: Console.WriteLine("Invalid manufacturer parameter."); ShowUsage(); return; } dp.OnDatabaseConnecting += (sender, conn) => Console.WriteLine("Connecting to \"{0}\"...", FilterPsw(conn)); dp.OnStartLoadDatabase += (sender, cmd) => Console.WriteLine("Retriving tables via {0}...", showStatement ? cmd : string.Empty); SourceView db = dp.GetSourceView(schemas, namelike, escapeTables, escapeColumns); WXMLModel model = null; if (File.Exists(file)) { if (merge == "error") { Console.WriteLine("The file " + file + " is already exists."); ShowUsage(); return; } Console.WriteLine("Loading file " + file); model = WXMLModel.LoadFromXml(new System.Xml.XmlTextReader(file)); } else { model = new WXMLModel(); model.Namespace = namesp; model.SchemaVersion = v; if (!Path.IsPathRooted(file)) { file = Path.Combine(Directory.GetCurrentDirectory(), file); } //File.Create(file); } SourceToModelConnector g = new SourceToModelConnector(db, model); Console.WriteLine("Generating xml..."); HashSet <EntityDefinition> ents = new HashSet <EntityDefinition>(); g.OnEntityCreated += (sender, entity) => { Console.WriteLine("Create class {0} ({1})", entity.Name, entity.Identifier); ents.Add(entity); }; g.OnPropertyCreated += (sender, prop, created) => { EntityDefinition entity = prop.Entity; if (!ents.Contains(entity)) { ents.Add(entity); Console.WriteLine("Alter class {0} ({1})", entity.Name, entity.Identifier); } Console.WriteLine("\t{1} property {2}.{0}", prop.Name, created ? "Add" : "Alter", entity.Name); }; g.OnPropertyRemoved += (sender, prop) => Console.WriteLine("Remove: {0}.{1}", prop.Entity.Name, prop.Name); g.ApplySourceViewToModel(dr, hie ? relation1to1.Hierarchy : unify ? relation1to1.Unify : relation1to1.Default, transform, capitalize, dp.CaseSensitive); using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(file, Encoding.UTF8)) { writer.Formatting = System.Xml.Formatting.Indented; model.GetXmlDocument().Save(writer); } Console.WriteLine("Done!"); //Console.ReadKey(); }
private GentleProviders() { MySQLProvider prov1 = new MySQLProvider(""); SQLServerProvider prov2 = new SQLServerProvider(""); }