|
4 | 4 | using NetTaste; |
5 | 5 | using System; |
6 | 6 | using System.Collections.Generic; |
| 7 | +using System.Data; |
| 8 | +using System.Data.Common; |
7 | 9 | using Xunit; |
8 | 10 |
|
9 | 11 | namespace FreeSql.Tests.SqlServer |
@@ -43,20 +45,56 @@ public void ExecuteReader() |
43 | 45 | [Fact] |
44 | 46 | public void ExecuteArray() |
45 | 47 | { |
46 | | - |
| 48 | + |
47 | 49 | } |
48 | 50 | [Fact] |
49 | 51 | public void ExecuteNonQuery() |
50 | 52 | { |
51 | 53 | var ps = new[] |
52 | 54 | { |
53 | 55 | new SqlParameter("@TableName", "tb1"), |
54 | | - new SqlParameter("@FInterID", System.Data.SqlDbType.Int) |
| 56 | + new SqlParameter("@FInterID", SqlDbType.Int) |
55 | 57 | }; |
56 | 58 | ps[1].Direction = System.Data.ParameterDirection.Output; |
57 | | - g.sqlserver.Ado.ExecuteNonQuery(System.Data.CommandType.StoredProcedure, "dbo.GetICMaxNum", ps); |
| 59 | + g.sqlserver.Ado.ExecuteNonQuery(CommandType.StoredProcedure, "dbo.GetICMaxNum", ps); |
58 | 60 | Assert.Equal(100, ps[1].Value); |
59 | 61 | } |
| 62 | + |
| 63 | + [Fact] |
| 64 | + public void ComandFluent() |
| 65 | + { |
| 66 | + var fsql = g.sqlserver; |
| 67 | + |
| 68 | + DbParameter p2 = null; |
| 69 | + fsql.Ado.CommandFluent("dbo.GetICMaxNum") |
| 70 | + .CommandType(CommandType.StoredProcedure) |
| 71 | + .WithParameter("TableName", "tb1") |
| 72 | + .WithParameter("FInterID", null, p => |
| 73 | + { |
| 74 | + p2 = p; |
| 75 | + p.DbType = DbType.Int32; |
| 76 | + p.Direction = ParameterDirection.Output; |
| 77 | + }) |
| 78 | + .ExecuteNonQuery(); |
| 79 | + Assert.Equal(100, p2.Value); |
| 80 | + |
| 81 | + DbParameter p3 = null; |
| 82 | + fsql.Ado.CommandFluent("dbo.GetICMaxNum", new Dictionary<string, object> |
| 83 | + { |
| 84 | + ["TableName"] = "tb1" |
| 85 | + // ¸ü¶à²ÎÊý |
| 86 | + }) |
| 87 | + .WithParameter("FInterID", null, p => |
| 88 | + { |
| 89 | + p3 = p; |
| 90 | + p.DbType = DbType.Int32; |
| 91 | + p.Direction = ParameterDirection.Output; |
| 92 | + }) |
| 93 | + .CommandType(CommandType.StoredProcedure) |
| 94 | + .ExecuteNonQuery(); |
| 95 | + Assert.Equal(100, p3.Value); |
| 96 | + } |
| 97 | + |
60 | 98 | [Fact] |
61 | 99 | public void ExecuteScalar() |
62 | 100 | { |
|
0 commit comments