Last active
November 2, 2017 10:56
-
-
Save thiagoloureiro/7d8fab3eed2e5a6f8bb8639a0c65ff54 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Configuration; | |
using MySql.Data.MySqlClient; | |
namespace Data.Dapper.Class | |
{ | |
public abstract class BaseRepository | |
{ | |
public string connstringSQL = ConfigurationManager.ConnectionStrings["SqlServerConnString"].ConnectionString; | |
public MySqlConnection GetMySqlConnection(bool open = true, | |
bool convertZeroDatetime = false, bool allowZeroDatetime = false) | |
{ | |
string cs = "Server=xxx;Port=41890;Database=yyy;Uid=zzz;Pwd=db;"; | |
var csb = new MySqlConnectionStringBuilder(cs) | |
{ | |
AllowZeroDateTime = allowZeroDatetime, | |
ConvertZeroDateTime = convertZeroDatetime | |
}; | |
var conn = new MySqlConnection(csb.ConnectionString); | |
if (open) conn.Open(); | |
return conn; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment