Browse Source

Update Unit Test

pull/12/MERGE
sunkaixuan 6 years ago
parent
commit
21d971e18b
  1. 41
      Src/Asp.Net/SqlServerTest/UnitTest/UAdo.cs
  2. 4
      Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs
  3. 4
      Src/Asp.Net/SqlSugar/Interface/IAdo.cs

41
Src/Asp.Net/SqlServerTest/UnitTest/UAdo.cs

@ -4,12 +4,49 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
namespace OrmTest
{
public partial class NewUnitTest
{
public static void Ado() {
public static void Ado()
{
var task1 = Db.Ado.GetScalarAsync("select 1");
task1.Wait();
UValidate.Check(1, task1.Result, "ado");
var task2 = Db.Ado.GetIntAsync("select 2");
task2.Wait();
UValidate.Check(2, task2.Result, "ado");
var task3 = Db.Ado.GetLongAsync("select 3");
task3.Wait();
UValidate.Check(3, task3.Result, "ado");
var task4 = Db.Ado.GetDataTableAsync("select 4 as id");
task4.Wait();
UValidate.Check(4, task4.Result.Rows[0]["id"], "ado");
var task5 = Db.Ado.GetInt("select @id as id",new { id=5});
UValidate.Check(5, task5, "ado");
var task6 = Db.Ado.SqlQuery<dynamic>("select @id as id", new { id = 5 });
UValidate.Check(5, task6[0].id, "ado");
var task7 = Db.Ado.SqlQueryAsync<dynamic>("select @id as id", new { id = 7 });
task7.Wait();
UValidate.Check(7, task7.Result[0].id, "ado");
var task8 = Db.Ado.SqlQueryAsync<dynamic>("select 8 as id");
task8.Wait();
UValidate.Check(8, task8.Result[0].id, "ado");
}
}
}

4
Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs

@ -592,11 +592,11 @@ namespace SqlSugar
public virtual long GetLong(string sql, object parameters)
public virtual long GetLong(string sql, object parameters=null)
{
return Convert.ToInt64(GetScalar(sql, GetParameters(parameters)));
}
public virtual async Task<long> GetLongAsync(string sql, object parameters)
public virtual async Task<long> GetLongAsync(string sql, object parameters=null)
{
return Convert.ToInt64(await GetScalarAsync(sql, GetParameters(parameters)));
}

4
Src/Asp.Net/SqlSugar/Interface/IAdo.cs

@ -94,9 +94,9 @@ namespace SqlSugar
Task<int> GetIntAsync(string sql, List<SugarParameter> parameters);
long GetLong(string sql, object pars);
long GetLong(string sql, object pars=null);
Task<long> GetLongAsync(string sql, object pars);
Task<long> GetLongAsync(string sql, object pars=null);
Double GetDouble(string sql, object parameters);

Loading…
Cancel
Save