Skip to content

Commit

Permalink
优化代码:RepositoryBase 增加ISqlResource字段;基础sql 增加虚方法
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzhiyuan committed May 7, 2024
1 parent 924f8e8 commit 16b807e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/NuClear.Dapper/RepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using NuClear.Dapper.AggregateQueryObject;
using NuClear.Dapper.Context;
using NuClear.Dapper.QueryObject;
using NuClear.Dapper.SqlResources;
using System;
using System.Collections.Generic;
using System.Data;
Expand All @@ -17,6 +18,7 @@ public abstract class RepositoryBase<TEntity> : IRepository<TEntity> where TEnti
protected abstract IAggrQuerySqlParser AggrQuerySqlParser { get; }
protected abstract ISqlParser SqlParser { get; }
protected abstract ICriterionSqlParser CriterionSqlParser { get; }
protected abstract ISqlResource<TEntity> SqlResource { get; }

protected IDbConnection Conn { get { return Context.Connection; } }
protected IDbTransaction Tran { get { return Context.Transaction; } }
Expand Down Expand Up @@ -85,7 +87,6 @@ protected async Task<IEnumerable<TReturn>> InternalQueryAsync<TFirst, TSecond, T

#endregion


#region FirstOrDefault

public virtual TEntity FirstOrDefault(string id)
Expand Down Expand Up @@ -156,7 +157,7 @@ public virtual async Task<int> CountAsync(Query query)
string whereSql = GetWhereSql(query, out object param);
return await this.CountAsync(CombineCountSql(this.SelectSql, whereSql), param);
}

#endregion

#region Exists
Expand Down Expand Up @@ -684,10 +685,10 @@ public void Dispose()

#region Sql
public virtual string TableAliasName { get { return ""; } }
public abstract string SelectSql { get; }
public abstract string InsertSql { get; }
public abstract string UpdateSql { get; }
public abstract string DeleteSql { get; }
public virtual string SelectSql { get { return SqlResource.Select; } }
public virtual string InsertSql { get { return SqlResource.Insert; } }
public virtual string UpdateSql { get { return SqlResource.Update; } }
public virtual string DeleteSql { get { return SqlResource.Delete; } }
#endregion
}
}

0 comments on commit 16b807e

Please sign in to comment.