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