Skip to content

Commit e61249a

Browse files
committed
add SqlParameter default Ctor
1 parent ebd3909 commit e61249a

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

build/version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<VersionMajor>4</VersionMajor>
44
<VersionMinor>0</VersionMinor>
5-
<VersionPatch>8</VersionPatch>
5+
<VersionPatch>10</VersionPatch>
66
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
77
</PropertyGroup>
88
</Project>

src/SmartSql.Test.Unit/DbSessions/DbSessionTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ public void DeleteCheckIsNotEmptyRequired()
235235
public void SP()
236236
{
237237
SqlParameterCollection dbParameterCollection = new SqlParameterCollection();
238-
dbParameterCollection.Add(new SqlParameter("Total",null,typeof(int))
238+
dbParameterCollection.Add(new SqlParameter
239239
{
240+
Name = "Total",
240241
DbType = System.Data.DbType.Int32,
241242
Direction = System.Data.ParameterDirection.Output
242243
});

src/SmartSql/Data/SqlParameter.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,38 @@ namespace SmartSql.Data
1010
public class SqlParameter
1111
{
1212
private DbParameter _sourceParameter;
13+
private object _value;
14+
public SqlParameter()
15+
{
16+
}
17+
public SqlParameter(string name, object val)
18+
{
19+
Name = name;
20+
Value = val;
21+
if (val != null)
22+
{
23+
ParameterType = val.GetType();
24+
}
25+
}
1326
public SqlParameter(string name, object val, Type parameterType)
1427
{
1528
Name = name;
1629
Value = val;
1730
ParameterType = parameterType;
1831
}
1932
public string Name { get; set; }
20-
public object Value { get; set; }
33+
public object Value
34+
{
35+
get => _value;
36+
set
37+
{
38+
_value = value;
39+
if (value != null)
40+
{
41+
ParameterType = value.GetType();
42+
}
43+
}
44+
}
2145
public Type ParameterType { get; set; }
2246
public Action<SqlParameter> OnSetSourceParameter { get; set; }
2347

0 commit comments

Comments
 (0)