antonheryanto / dapper-rainbow-mysql Goto Github PK
View Code? Open in Web Editor NEWDapper Rainbow for MySQL based on https://github.com/StackExchange/dapper-dot-net
Dapper Rainbow for MySQL based on https://github.com/StackExchange/dapper-dot-net
Would adding in dynamic table generation be a bad idea? I have already completed most of this but I am wondering if it is okay for me to continue to make pull requests.
I'm not looking for anything overly verbose, but having a simple decorator on properties and classes should your database schema have different naming would be nice.
it possible to use sql query?
when i make a property with type: Table<T, TId> in Database...I found that can't work.. the Table<T,TId> property of Database will be null at runtime....
Is the model key can't be other type except long?
采用这种方式进行数据库操作:
每次CRUD都会创建1个新的数据库链接 然后不能释放 一会儿就好几百个数据库链接了
改怎么改造呢?
public class DbContextFactory
{
public static DbContext GetDb(string connString)
{
DbConnection connection = new SqlConnection(connString);
if (connection.State != System.Data.ConnectionState.Open)
connection.Open();
DbContext dbContext = DbContext.Init(connection, 60);
return dbContext;
}
public static DbContext Default
{
get { return GetDb(Config.connString); }
}
}
I need install on Windows XP and I need complile in framework 4.0 fot this.
Dapper is able.
Is able the Rainbow?
thanks
var sql = $"SELECT * FROM {TableName}";
Tablename is missing a single quote.
When I use the InsertOrUpdate function of the Rainbow, it returns 1 when it inserts and 2 when it updates. How can I get the id of the object that has been updated or inserted?
I have the version of dapper 1.50.2 and of Rainbow.MySql 0.10.1
Code:
public static Tuple<int, int> AddOrUpdateSesionCarrera(sesiones sesion, out Pk15Error pk15error)
{
pk15error = new Pk15Error();
try
{
using (var transaction = new TransactionScope())
{
// Operaciones sobre la base de datos.
Db newdb = IVS_OpenConnection.db;
OpenConnectionInstance connect = null;
if (!string.IsNullOrEmpty(IVS_OpenConnection.CadenaConexion))
{
connect = new OpenConnectionInstance(IVS_OpenConnection.CadenaConexion);
newdb = connect.db;
}
if (sesion.carrera != null)
{
var sesionId = newdb.Sesiones.InsertOrUpdate(sesion); //TODO InsertOrUpdate not return id.
sesion.carrera.idSesion = (int)sesionId;
var carreraId = newdb.Carrera.InsertOrUpdate(sesion.carrera);
connect?.Dispose();
/* Devolvemos el id de la sesion */
return new Tuple<int, int>((int)sesionId, (int)carreraId);
}
// Aceptamos la transacción.
transaction.Complete();
}
}
catch (OpenConexionDbException e)
{
pk15error.exception = e;
pk15error.errorType = EnumeradosIVS.TDapperError.DatabaseConnection;
return null;
}
catch (Exception e)
{
pk15error.exception = e;
pk15error.errorType = EnumeradosIVS.TDapperError.DatabaseQuery;
error.EscribeErrorBD("Error AddSesionCarrera: " + e.Message);
throw new Exception("Error AddSesionCarrera: " + e.Message);
}
return null;
}
Thank you @antonheryanto
when i use the method by sql with "order by" .. there will be throw an exception...
to debug the source.. then i have to change the code line of Page.cs:
var sqlCount = string.Format ("{0} COUNT({1}) {2}", sql.Substring (0, g.Index), count, sql.Substring (g.Index + g.Length));
to be this:
var sqlCount = string.Format ("{0} COUNT({1}) from ({2}) as {3}
", sql.Substring (0, g.Index), count, sql, new Guid().ToString());
can you update this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.