Browse Source

-

pull/12/MERGE
sunkaixuan 8 years ago
parent
commit
8ab8687ae1
  1. BIN
      .vs/SqlSugar/v14/.suo
  2. BIN
      OrmTest/bin/Debug/OrmTest.exe
  3. BIN
      OrmTest/bin/Debug/OrmTest.pdb
  4. BIN
      OrmTest/bin/Debug/SqlSugar.dll
  5. BIN
      OrmTest/bin/Debug/SqlSugar.pdb
  6. BIN
      OrmTest/obj/Debug/OrmTest.csprojResolveAssemblyReference.cache
  7. BIN
      OrmTest/obj/Debug/OrmTest.exe
  8. BIN
      OrmTest/obj/Debug/OrmTest.pdb
  9. 26
      SqlSugar/Abstract/DbProvider/DbAccessory.cs
  10. 28
      SqlSugar/Abstract/DbProvider/DbProvider.cs
  11. 8
      SqlSugar/Abstract/QueryableProvider/QueryableAccessory.cs
  12. 4
      SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  13. 4
      SqlSugar/Databases/SqlServer/Db/SqlServerDb.cs
  14. 65
      SqlSugar/Entities/SugarParameter.cs
  15. 28
      SqlSugar/Interface/IDb.cs
  16. 2
      SqlSugar/Interface/IQueryable.cs
  17. 1
      SqlSugar/SqlSugar.csproj
  18. BIN
      SqlSugar/bin/Debug/SqlSugar.dll
  19. BIN
      SqlSugar/bin/Debug/SqlSugar.pdb
  20. BIN
      SqlSugar/obj/Debug/SqlSugar.dll
  21. BIN
      SqlSugar/obj/Debug/SqlSugar.pdb

BIN
.vs/SqlSugar/v14/.suo

Binary file not shown.

BIN
OrmTest/bin/Debug/OrmTest.exe

Binary file not shown.

BIN
OrmTest/bin/Debug/OrmTest.pdb

Binary file not shown.

BIN
OrmTest/bin/Debug/SqlSugar.dll

Binary file not shown.

BIN
OrmTest/bin/Debug/SqlSugar.pdb

Binary file not shown.

BIN
OrmTest/obj/Debug/OrmTest.csprojResolveAssemblyReference.cache

Binary file not shown.

BIN
OrmTest/obj/Debug/OrmTest.exe

Binary file not shown.

BIN
OrmTest/obj/Debug/OrmTest.pdb

Binary file not shown.

26
SqlSugar/Abstract/DbProvider/DbAccessory.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
@ -14,7 +15,7 @@ namespace SqlSugar
protected ICodeFirst _CodeFirst;
protected IDbMaintenance _DbMaintenance;
protected IDbConnection _DbConnection;
public virtual void SetParSize(SqlParameter[] pars)
public virtual void SetParSize(SugarParameter[] pars)
{
if (pars != null)
{
@ -24,7 +25,7 @@ namespace SqlSugar
}
}
}
public virtual void SetParSize(SqlParameter par)
public virtual void SetParSize(SugarParameter par)
{
int size = par.Size;
if (size < 4000)
@ -33,19 +34,14 @@ namespace SqlSugar
}
}
public virtual void SetSqlDbType(PropertyInfo prop, SqlParameter par)
public virtual void SetSqlDbType(PropertyInfo prop, SugarParameter par)
{
var isNullable = false;
var isByteArray = PubMethod.GetUnderType(prop, ref isNullable) == typeof(byte[]);
if (isByteArray)
{
par.SqlDbType = SqlDbType.VarBinary;
}
}
protected virtual SqlParameter[] GetParameters(object obj, PropertyInfo[] propertyInfo,string sqlParameterKeyWord)
protected virtual SugarParameter[] GetParameters(object obj, PropertyInfo[] propertyInfo,string sqlParameterKeyWord)
{
List<SqlParameter> listParams = new List<SqlParameter>();
List<SugarParameter> listParams = new List<SugarParameter>();
if (obj != null)
{
var type = obj.GetType();
@ -55,7 +51,7 @@ namespace SqlSugar
if (type == PubConst.DicArraySO)
{
var newObj = (Dictionary<string, object>)obj;
var pars = newObj.Select(it => new SqlParameter(sqlParameterKeyWord + it.Key, it.Value));
var pars = newObj.Select(it => new SugarParameter(sqlParameterKeyWord + it.Key, it.Value));
foreach (var par in pars)
{
SetParSize(par);
@ -66,7 +62,7 @@ namespace SqlSugar
{
var newObj = (Dictionary<string, string>)obj;
var pars = newObj.Select(it => new SqlParameter(sqlParameterKeyWord + it.Key, it.Value));
var pars = newObj.Select(it => new SugarParameter(sqlParameterKeyWord + it.Key, it.Value));
foreach (var par in pars)
{
SetParSize(par);
@ -96,14 +92,14 @@ namespace SqlSugar
if (value == null || value.Equals(DateTime.MinValue)) value = DBNull.Value;
if (r.Name.ToLower().Contains("hierarchyid"))
{
var par = new SqlParameter(sqlParameterKeyWord + r.Name, SqlDbType.Udt);
var par = new SugarParameter(sqlParameterKeyWord + r.Name, SqlDbType.Udt);
par.UdtTypeName = "HIERARCHYID";
par.Value = value;
listParams.Add(par);
}
else
{
var par = new SqlParameter(sqlParameterKeyWord + r.Name, value);
var par = new SugarParameter(sqlParameterKeyWord + r.Name, value);
SetParSize(par);
if (value == DBNull.Value)
{//防止文件类型报错

28
SqlSugar/Abstract/DbProvider/DbProvider.cs

@ -125,7 +125,7 @@ namespace SqlSugar
{
return GetString(sql, this.GetParameters(pars));
}
public virtual string GetString(string sql, params SqlParameter[] pars)
public virtual string GetString(string sql, params SugarParameter[] pars)
{
return Convert.ToString(GetScalar(sql, pars));
}
@ -133,24 +133,24 @@ namespace SqlSugar
{
return GetInt(sql, this.GetParameters(pars));
}
public virtual int GetInt(string sql, params SqlParameter[] pars)
public virtual int GetInt(string sql, params SugarParameter[] pars)
{
return Convert.ToInt32(GetScalar(sql, pars));
}
public virtual Double GetDouble(string sql, params SqlParameter[] pars)
public virtual Double GetDouble(string sql, params SugarParameter[] pars)
{
return Convert.ToDouble(GetScalar(sql, pars));
}
public virtual decimal GetDecimal(string sql, params SqlParameter[] pars)
public virtual decimal GetDecimal(string sql, params SugarParameter[] pars)
{
return Convert.ToDecimal(GetScalar(sql, pars));
}
public virtual DateTime GetDateTime(string sql, params SqlParameter[] pars)
public virtual DateTime GetDateTime(string sql, params SugarParameter[] pars)
{
return Convert.ToDateTime(GetScalar(sql, pars));
}
public virtual SqlParameter[] GetParameters(object obj, PropertyInfo[] propertyInfo = null)
public virtual SugarParameter[] GetParameters(object obj, PropertyInfo[] propertyInfo = null)
{
if (obj == null) return null;
return base.GetParameters(obj, propertyInfo,this.Context.SqlBuilder.SqlParameterKeyWord);
@ -180,16 +180,16 @@ namespace SqlSugar
this.Transaction = null;
}
}
public abstract IDbDataParameter[] ToIDbDataParameter(params SqlParameter[] pars);
public abstract SugarParameter[] ToIDbDataParameter(params SugarParameter[] pars);
public abstract void SetCommandToAdapter(IDataAdapter adapter, IDbCommand command);
public abstract IDataAdapter GetAdapter();
public abstract IDbCommand GetCommand(string sql, SqlParameter[] pars);
public abstract IDbCommand GetCommand(string sql, SugarParameter[] pars);
public abstract IDbConnection Connection { get; set; }
public abstract void BeginTran(string transactionName);//Only SqlServer
public abstract void BeginTran(IsolationLevel iso, string transactionName);//Only SqlServer
#region Core
public virtual int ExecuteCommand(string sql, params SqlParameter[] pars)
public virtual int ExecuteCommand(string sql, params SugarParameter[] pars)
{
base.SetParSize(pars);
ExecLogEvent(sql, pars, true);
@ -200,7 +200,7 @@ namespace SqlSugar
ExecLogEvent(sql, pars, false);
return count;
}
public virtual IDataReader GetDataReader(string sql, params SqlParameter[] pars)
public virtual IDataReader GetDataReader(string sql, params SugarParameter[] pars)
{
base.SetParSize(pars);
ExecLogEvent(sql, pars, true);
@ -211,7 +211,7 @@ namespace SqlSugar
ExecLogEvent(sql, pars, false);
return sqlDataReader;
}
public virtual DataSet GetDataSetAll(string sql, params SqlParameter[] pars)
public virtual DataSet GetDataSetAll(string sql, params SugarParameter[] pars)
{
base.SetParSize(pars);
ExecLogEvent(sql, pars, true);
@ -225,7 +225,7 @@ namespace SqlSugar
ExecLogEvent(sql, pars, false);
return ds;
}
public virtual object GetScalar(string sql, params SqlParameter[] pars)
public virtual object GetScalar(string sql, params SugarParameter[] pars)
{
base.SetParSize(pars);
ExecLogEvent(sql, pars, true);
@ -239,7 +239,7 @@ namespace SqlSugar
}
#endregion
public virtual DataTable GetDataTable(string sql, params SqlParameter[] pars)
public virtual DataTable GetDataTable(string sql, params SugarParameter[] pars)
{
var ds = GetDataSetAll(sql, pars);
if (ds.Tables.Count != 0 && ds.Tables.Count > 0) return ds.Tables[0];
@ -265,7 +265,7 @@ namespace SqlSugar
{
return ExecuteCommand(sql, GetParameters(pars));
}
public virtual void ExecLogEvent(string sql, SqlParameter[] pars, bool isStarting = true)
public virtual void ExecLogEvent(string sql, SugarParameter[] pars, bool isStarting = true)
{
if (this.IsEnableLogEvent)
{

8
SqlSugar/Abstract/QueryableProvider/QueryableAccessory.cs

@ -9,19 +9,19 @@ namespace SqlSugar
{
public class QueryableAccessory
{
protected List<SqlParameter> _Pars;
protected List<SugarParameter> _Pars;
protected void AddPars(object whereObj, SqlSugarClient context)
{
var sqlParsArray = context.Database.GetParameters(whereObj);
if (_Pars == null)
_Pars = new List<SqlParameter>();
_Pars = new List<SugarParameter>();
if (sqlParsArray != null)
_Pars.AddRange(sqlParsArray);
}
protected void AddPars(List<SqlParameter> pars, SqlSugarClient context)
protected void AddPars(List<SugarParameter> pars, SqlSugarClient context)
{
if (_Pars == null)
_Pars = new List<SqlParameter>();
_Pars = new List<SugarParameter>();
if (pars != null)
_Pars.AddRange(pars);
}

4
SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -15,9 +15,9 @@ namespace SqlSugar
public IDb Db { get { return Context.Database; } }
public IDbBind Bind { get { return this.Db.DbBind; } }
public ISqlBuilder SqlBuilder { get { return this.Context.SqlBuilder; } }
public List<SqlParameter> Pars
public List<SugarParameter> Pars
{
get { return PubMethod.IsNullReturnNew<List<SqlParameter>>(base._Pars); }
get { return PubMethod.IsNullReturnNew<List<SugarParameter>>(base._Pars); }
set { base._Pars = value; }
}
public void Clear()

4
SqlSugar/Databases/SqlServer/Db/SqlServerDb.cs

@ -46,7 +46,7 @@ namespace SqlSugar
{
return new SqlDataAdapter();
}
public override IDbCommand GetCommand(string sql, SqlParameter[] pars)
public override IDbCommand GetCommand(string sql, SugarParameter[] pars)
{
SqlCommand sqlCommand = new SqlCommand(sql, (SqlConnection)this.Connection);
sqlCommand.CommandType = this.CommandType;
@ -73,7 +73,7 @@ namespace SqlSugar
/// </summary>
/// <param name="pars"></param>
/// <returns></returns>
public override IDbDataParameter[] ToIDbDataParameter(params SqlParameter[] pars)
public override SugarParameter[] ToIDbDataParameter(params SugarParameter[] pars)
{
return pars;
}

65
SqlSugar/Entities/SugarParameter.cs

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class SugarParameter : DbParameter
{
public SugarParameter(string name, object value)
{
this.Value = value;
this.ParameterName = name;
}
public override System.Data.DbType DbType
{
get;set;
}
public override ParameterDirection Direction
{
get;set;
}
public override bool IsNullable
{
get;set;
}
public override string ParameterName
{
get;set;
}
public override int Size
{
get;set;
}
public override string SourceColumn
{
get;set;
}
public override bool SourceColumnNullMapping
{
get;set;
}
public string UdtTypeName { get; internal set; }
public override object Value
{
get;set;
}
public override void ResetDbType()
{
this.DbType = System.Data.DbType.String;
}
}
}

28
SqlSugar/Interface/IDb.cs

@ -13,10 +13,10 @@ namespace SqlSugar
{
IDbConnection Connection { get; set; }
IDbTransaction Transaction { get; set; }
IDbDataParameter[] ToIDbDataParameter(params SqlParameter [] pars);
SqlParameter[] GetParameters(object obj, PropertyInfo[] propertyInfo = null);
SugarParameter[] ToIDbDataParameter(params SugarParameter[] pars);
SugarParameter[] GetParameters(object obj, PropertyInfo[] propertyInfo = null);
SqlSugarClient Context { get; set; }
void ExecLogEvent(string sql, SqlParameter[] pars, bool isStarting = true);
void ExecLogEvent(string sql, SugarParameter[] pars, bool isStarting = true);
IConnectionConfig MasterConnectionConfig { get; set; }
List<IConnectionConfig> SlaveConnectionConfigs { get; set; }
@ -35,24 +35,24 @@ namespace SqlSugar
void SetCommandToAdapter(IDataAdapter adapter,IDbCommand command);
IDataAdapter GetAdapter();
IDbCommand GetCommand(string sql, SqlParameter[] pars);
IDbCommand GetCommand(string sql, SugarParameter[] pars);
DataTable GetDataTable(string sql, object pars);
DataTable GetDataTable(string sql, params SqlParameter[] pars);
DataTable GetDataTable(string sql, params SugarParameter[] pars);
DataSet GetDataSetAll(string sql, object pars);
DataSet GetDataSetAll(string sql, params SqlParameter[] pars);
DataSet GetDataSetAll(string sql, params SugarParameter[] pars);
IDataReader GetDataReader(string sql,object pars);
IDataReader GetDataReader(string sql, params SqlParameter[] pars);
IDataReader GetDataReader(string sql, params SugarParameter[] pars);
object GetScalar(string sql, object pars);
object GetScalar(string sql, params SqlParameter[] pars);
object GetScalar(string sql, params SugarParameter[] pars);
int ExecuteCommand(string sql, object pars);
int ExecuteCommand(string sql, params SqlParameter[] pars);
int ExecuteCommand(string sql, params SugarParameter[] pars);
string GetString(string sql, object pars);
string GetString(string sql, params SqlParameter[] pars);
string GetString(string sql, params SugarParameter[] pars);
int GetInt(string sql, object pars);
int GetInt(string sql, params SqlParameter[] pars);
Double GetDouble(string sql, params SqlParameter[] pars);
decimal GetDecimal(string sql, params SqlParameter[] pars);
DateTime GetDateTime(string sql, params SqlParameter[] pars);
int GetInt(string sql, params SugarParameter[] pars);
Double GetDouble(string sql, params SugarParameter[] pars);
decimal GetDecimal(string sql, params SugarParameter[] pars);
DateTime GetDateTime(string sql, params SugarParameter[] pars);
void Dispose();
void Close();

2
SqlSugar/Interface/IQueryable.cs

@ -10,7 +10,7 @@ namespace SqlSugar
public partial interface ISugarQueryable<T> where T : class, new()
{
SqlSugarClient Context { get; set; }
List<SqlParameter> Pars { get; set; }
List<SugarParameter> Pars { get; set; }
ISugarQueryable<T> Where(Expression<Func<T, bool>> expression);

1
SqlSugar/SqlSugar.csproj

@ -97,6 +97,7 @@
<Compile Include="Entities\ConnectionConfig.cs" />
<Compile Include="Entities\DbColumnInfo.cs" />
<Compile Include="Entities\DbTableInfo.cs" />
<Compile Include="Entities\SugarParameter.cs" />
<Compile Include="ExpressionsToSql\ExpressionParameter.cs" />
<Compile Include="Entities\JoinQueryInfo.cs" />
<Compile Include="Entities\Mapping\MappingColumn.cs" />

BIN
SqlSugar/bin/Debug/SqlSugar.dll

Binary file not shown.

BIN
SqlSugar/bin/Debug/SqlSugar.pdb

Binary file not shown.

BIN
SqlSugar/obj/Debug/SqlSugar.dll

Binary file not shown.

BIN
SqlSugar/obj/Debug/SqlSugar.pdb

Binary file not shown.
Loading…
Cancel
Save