GithubHelp home page GithubHelp logo

dbhelpers's People

Contributors

nvivo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dbhelpers's Issues

Stop using Task.Run

Some methods like ExecuteDataTableAsync/ExecuteDataSetAsync call Task.Run unnecessarily. This should be removed.

Improve DataReaderConverter to accept more types

Current DataReaderConverter uses System.Convert for type conversions, which doesn't handle nullable types.

It also needs a better converter that can handle other values that comes from databases, including DBNull.

Question List parameters support?

Hi, awesome work!
does nvivo dbhelps support this like following ?
"select * from (select 1 as Id union all select 2 union all select 3) as X where Id in @Ids",

Connection automatically closed after query

I would like to perform queries in transaction/ 1 connection, but ExecuteObject automatically closes connection. In case of provided connection, methoud should not close connection itself:

This works:
using (var connection = db.CreateConnection()) {
connection.Open();
db.ExecuteNonQuery(..., connection);
db.ExecuteNonQuery(..., connection);
db.ExecuteNonQuery(..., connection);
}

But this not:
using (var connection = db.CreateConnection()) {
connection.Open();
db.ExecuteObject(..., connection);
db.ExecuteObject(..., connection); // connection closed exception
db.ExecuteObject(..., connection);
}

Cause: CommandBehavior.CloseConnection in ExecuteReader method

Transactions

Hello there,

Thanks for the code...

Is there support for transactions?

Regards.

Josep

Does not work at all. Connection not initialized

I tried using the DBHelper with the following:

_sourceDB = new DBHelper("Source");

here is the connection string defined
<add name="Source" connectionString="data source=workstation;initial catalog=MCQ;integrated security=True;multipleactiveresultsets=True;" providerName="System.Data.SqlClient" />

and it keeps giving error
Connection not initialized

Improve conversion experience

Today, DbDataReader exposes some methods like GetInt32(int) that allows fast data retrieval, but requires extra steps to check for DBNulls. It also doesn't provide methods to retrieve nullables neither handles field names, only ordinals.

class User {
    public string Name { get; set; }
    public int? Age { get; set; }
}

var user = db.ExecuteList("select name, age from users", r => new User {
    Name = r.IsDBNull(0) ? null : r.GetString(0),
    Age = r.IsDBNull(1) ? null : r.GetInt32(1)
});

DBConvert provides easier conversion methods, but the extra method call and method names like "ToNullableDateTimeOffset" makes the code a little bit harder to read.

var user = db.ExecuteList("select name, age from users", r => new User {
    Name = DBConvert.ToNullableInt32(r[0]),
    Age = DBConvert.ToString(r[1])
});

With extension methods, there could be a syntax like:

Name = reader.Get<string>(0);
Age = reader.Get<int?>(1);

Name = reader.Get<string>("name");
Age = reader.Get<int?>("age");

This would call the corresponding DBConvert method if needed.

ExecuteList<long> doesn't load long values

I'm trying to load List by using:
ExecuteList() from my database and it filled my result with 0 instead of 542496808.
My select would return only it: { ID: 542496808 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.