-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFuncScriptSql.cs
More file actions
34 lines (32 loc) · 1.14 KB
/
FuncScriptSql.cs
File metadata and controls
34 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Data.SqlTypes;
namespace FuncScript.Sql
{
public class FuncScriptSql
{
internal static object? NormalizeDataType(object obj)
{
return obj switch
{
DBNull => null,
SqlBinary sqlBinary => sqlBinary.Value,
SqlBoolean sqlBoolean => sqlBoolean.Value,
SqlDateTime sqlDateTime => sqlDateTime.Value,
SqlDecimal sqlDecimal => sqlDecimal.Value,
SqlDouble sqlDouble => sqlDouble.Value,
SqlGuid sqlGuid => sqlGuid.Value,
SqlInt16 sqlInt16 => sqlInt16.Value,
SqlInt32 sqlInt32 => sqlInt32.Value,
SqlInt64 sqlInt64 => sqlInt64.Value,
SqlSingle sqlSingle => sqlSingle.Value,
SqlString sqlString => RemoveNullBytes(sqlString.Value),
SqlMoney sqlMoney => sqlMoney.Value,
string str => RemoveNullBytes(str),
_ => obj,
};
}
private static string RemoveNullBytes(string str)
{
return str.Replace("\0", string.Empty);
}
}
}