Using NPoco in .net Core

I recently started diving into a new .net core with asp.net core mvc. There were several problems that I encountered, but they managed to get answers to most of them. The one who really alerted me is the use of NPoco.

How should you create a database instance?

The documentation reads:

IDatabase db = new Database("connStringName");
List<User> users = db.Fetch<User>("select userId, email from users");

This is not true for DNXCORE50, since this constructor was excluded for DNCORE50

I also tried to do this:

IDatabase _db = new Database(new SqlConnection(ConnStr));
_db.Single<string>("SELECT Username FROM dbo.Member");

When this code is running, I get a "NullReferenceException"

Does anyone know how to make NPoco work correctly?

+4
source share
2 answers

, . № 293 NPoco GitHub.

- DbProviderFactory, .

IDatabase _db = new Database(new SqlConnection(ConnStr),
                             DatabaseType.SqlServer2012, SqlClientFactory.Instance);
_db.Single<string>("SELECT Username FROM dbo.Member")
+1

NPoco ? , .NET Core 3.1/3.2 3.4.

project.json "NPoco": "3.3.4"?

0

All Articles