You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/DB/DbFactory.cs

33 lines
687 B
C#

6 months ago
using System.Data;
using Chloe;
using Chloe.PostgreSQL;
using Npgsql;
6 months ago
using Tool;
6 months ago
6 months ago
namespace DB
6 months ago
{
6 months ago
6 months ago
public class DbFactory
6 months ago
{
6 months ago
3 months ago
/// <summary>
/// 数据库访问类
/// </summary>
6 months ago
public static IDbContext GetContext
6 months ago
{
6 months ago
get
6 months ago
{
6 months ago
PostgreSQLContext context = new PostgreSQLContext(() =>
{
IDbConnection conn = new NpgsqlConnection(RfidSetting.Current.Db); //需要自己引入数据库驱动
return conn;
});
5 months ago
context.Options.ConvertToLowercase = true;
6 months ago
return context;
}
6 months ago
}
6 months ago
6 months ago
}
6 months ago
}