mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 01:58:13 +08:00
-
This commit is contained in:
@@ -7,8 +7,10 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SqlQueryBuilder:IDMLBuilder
|
||||
public class SqlQueryBuilder : IDMLBuilder
|
||||
{
|
||||
public SqlSugarClient Context { get; set; }
|
||||
|
||||
private string _Fields { get; set; }
|
||||
public string Fields
|
||||
{
|
||||
@@ -29,46 +31,47 @@ namespace SqlSugar
|
||||
_Fields = value;
|
||||
}
|
||||
}
|
||||
|
||||
private StringBuilder _Sql;
|
||||
public StringBuilder sql
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
_Sql = PubMethod.IsNullReturnNew(_Sql);
|
||||
return _Sql;
|
||||
}
|
||||
set {
|
||||
set
|
||||
{
|
||||
_Sql = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SqlSugarClient Context { get; set; }
|
||||
|
||||
public string SqlTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<SugarParameter> _Parameters;
|
||||
public List<SugarParameter> Parameters
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_Parameters = PubMethod.IsNullReturnNew(_Parameters);
|
||||
return _Parameters;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_Parameters = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string ToSqlString()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return sql.ToString();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
this.sql = null;
|
||||
|
@@ -243,12 +243,14 @@ namespace SqlSugar
|
||||
#endregion
|
||||
|
||||
#region SqlQuery
|
||||
public virtual List<T> SqlQuery<T>(string sql, object pars = null)
|
||||
public virtual List<T> SqlQuery<T>(string sql, object whereObj = null)
|
||||
{
|
||||
var dbPars = this.Database.GetParameters(pars);
|
||||
var dbPars = this.Database.GetParameters(whereObj);
|
||||
var builder = InstanceFactory.GetSqlbuilder(base.CurrentConnectionConfig);
|
||||
builder.SqlQueryBuilder.sql.Append(sql);
|
||||
using (var dataReader = this.Database.GetDataReader(sql, dbPars))
|
||||
if (dbPars != null && dbPars.Any())
|
||||
builder.SqlQueryBuilder.Parameters.AddRange(dbPars);
|
||||
using (var dataReader = this.Database.GetDataReader(builder.SqlQueryBuilder.ToSqlString(), builder.SqlQueryBuilder.Parameters.ToArray()))
|
||||
{
|
||||
var reval = this.Database.DbBind.DataReaderToList<T>(typeof(T), dataReader, builder.SqlQueryBuilder.Fields);
|
||||
if (this.CurrentConnectionConfig.IsAutoCloseConnection) this.Close();
|
||||
@@ -272,7 +274,7 @@ namespace SqlSugar
|
||||
{
|
||||
this.Database.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user