General.Entities/Dapper/DbRepository.cs
(开头部分) 19KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
namespace General.Entities.Dapper
{
public class DbRepository
{
private IDbConnection _connection { get; set; }
public string dbConnKey { get; set; }
public DbType dbType { get; set; }
public DbRepository(string dbConnKey, DbType dbType = DbType.SqlServer)
{
this.dbConnKey = dbConnKey;
this.dbType = dbType;
}
public DbRepository()
{
this.dbConnKey = "SqlServer";
}
public void Init(string dbConnKey, DbType dbType = DbType.SqlServer)
{
this.dbConnKey = dbConnKey;
this.dbType = dbType;
}
#region 属性
/// <summary>
/// 获取数据库连接
/// </summary>
public IDbConnection Connection
{
get
{
if (_connection == null)
{
_connection = DbConnectionFactory.GetConnection(dbConnKey, dbType);
}
return _connection;
}
}
/// <summary>
/// 事务对象
/// </summary>
public IDbTransaction dbTransaction { get; set; }
#endregion
#region 事务提交
/// <summary>
/// 事务开始
后面还有 460 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
