mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
optimization Sqllite dispose file occupied
This commit is contained in:
parent
a7678e9a7c
commit
ca550b4be1
@ -16,16 +16,16 @@ namespace OrmTest
|
||||
/// Account have permission to create database
|
||||
/// 用有建库权限的数据库账号
|
||||
/// </summary>
|
||||
public static string ConnectionString = "server=.;uid=sa;pwd=@jhl85661501;database=SQLSUGAR4XTEST";
|
||||
public static string ConnectionString = "server=.;uid=sa;pwd=haosql;database=SQLSUGAR4XTEST";
|
||||
/// <summary>
|
||||
/// Account have permission to create database
|
||||
/// 用有建库权限的数据库账号
|
||||
/// </summary>
|
||||
public static string ConnectionString2 = "server=.;uid=sa;pwd=@jhl85661501;database=SQLSUGAR4XTEST2";
|
||||
public static string ConnectionString2 = "server=.;uid=sa;pwd=haosql;database=SQLSUGAR4XTEST2";
|
||||
/// <summary>
|
||||
/// Account have permission to create database
|
||||
/// 用有建库权限的数据库账号
|
||||
/// </summary>
|
||||
public static string ConnectionString3 = "server=.;uid=sa;pwd=@jhl85661501;database=SQLSUGAR4XTEST3";
|
||||
public static string ConnectionString3 = "server=.;uid=sa;pwd=haosql;database=SQLSUGAR4XTEST3";
|
||||
}
|
||||
}
|
||||
|
@ -38,12 +38,28 @@ namespace OrmTest
|
||||
//sql
|
||||
var dt2 = db.Ado.GetDataTable("select * from [order] where @id>0 or name=@name", new { id = 1, name = "2" });
|
||||
|
||||
//Stored Procedure
|
||||
//var dt3 = db.Ado.UseStoredProcedure().GetDataTable("sp_school", new { name = "张三", age = 0 });
|
||||
//var nameP = new SugarParameter("@name", "张三");
|
||||
//var ageP = new SugarParameter("@age", null, true);//isOutput=true
|
||||
//var dt4 = db.Ado.UseStoredProcedure().GetDataTable("sp_school", nameP, ageP);
|
||||
|
||||
//create sp
|
||||
db.Ado.ExecuteCommand(@"
|
||||
if object_id('up_user') is not null
|
||||
drop proc up_user;");
|
||||
db.Ado.ExecuteCommand(@"
|
||||
create proc up_user
|
||||
@id int,
|
||||
@name varchar(10) ='' output
|
||||
as
|
||||
|
||||
begin
|
||||
set @name='abc'
|
||||
select @id as id
|
||||
end
|
||||
");
|
||||
//get output
|
||||
var dt3 = db.Ado.UseStoredProcedure().GetDataTable("up_user", new { name = "张三", id = 0 });
|
||||
var IdP = new SugarParameter("@id", 1);
|
||||
var NameP = new SugarParameter("@name", null, true);//isOutput=true
|
||||
var dt4 = db.Ado.UseStoredProcedure().GetDataTable("up_user", IdP, NameP);
|
||||
var outputValue = NameP.Value;
|
||||
|
||||
|
||||
//There are many methods to under db.ado
|
||||
|
@ -34,7 +34,7 @@ namespace OrmTest
|
||||
DemoG_SimpleClient.Init();
|
||||
|
||||
//Unit test
|
||||
//NewUnitTest.Init();
|
||||
NewUnitTest.Init();
|
||||
|
||||
//Rest Data
|
||||
NewUnitTest.RestData();
|
||||
|
@ -275,6 +275,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return count;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -310,6 +311,7 @@ namespace SqlSugar
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
SetConnectionEnd(sql);
|
||||
sqlCommand.Dispose();
|
||||
return sqlDataReader;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -339,6 +341,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return ds;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -371,6 +374,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return scalar;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -404,6 +408,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return count;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -440,6 +445,7 @@ namespace SqlSugar
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
SetConnectionEnd(sql);
|
||||
sqlCommand.Dispose();
|
||||
return sqlDataReader;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -468,6 +474,7 @@ namespace SqlSugar
|
||||
if (this.IsClearParameters)
|
||||
sqlCommand.Parameters.Clear();
|
||||
ExecuteAfter(sql, parameters);
|
||||
sqlCommand.Dispose();
|
||||
return scalar;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
Reference in New Issue
Block a user