mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-23 04:23:47 +08:00
Update .net
This commit is contained in:
12
Src/Asp.Net/SqlSugar/Infrastructure/StaticConfig.cs
Normal file
12
Src/Asp.Net/SqlSugar/Infrastructure/StaticConfig.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class StaticConfig
|
||||||
|
{
|
||||||
|
public static Func<string,string> Encode { get; set; }
|
||||||
|
public static Func<string,string> Decode{ get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -99,6 +99,7 @@
|
|||||||
<Compile Include="Entities\JoinMapper.cs" />
|
<Compile Include="Entities\JoinMapper.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Subquery\SubTemplate.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\SubTemplate.cs" />
|
||||||
<Compile Include="ExpressionsToSql\Subquery\SubqueryableN.cs" />
|
<Compile Include="ExpressionsToSql\Subquery\SubqueryableN.cs" />
|
||||||
|
<Compile Include="Infrastructure\StaticConfig.cs" />
|
||||||
<Compile Include="Interface\IFastBuilder.cs" />
|
<Compile Include="Interface\IFastBuilder.cs" />
|
||||||
<Compile Include="Interface\IFastest.cs" />
|
<Compile Include="Interface\IFastest.cs" />
|
||||||
<Compile Include="OnlyNet\OracleFastBuilder.cs" />
|
<Compile Include="OnlyNet\OracleFastBuilder.cs" />
|
||||||
|
@@ -344,6 +344,10 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public static string EncodeBase64(string code)
|
public static string EncodeBase64(string code)
|
||||||
{
|
{
|
||||||
|
if (StaticConfig.Encode != null)
|
||||||
|
{
|
||||||
|
return StaticConfig.Encode(code);
|
||||||
|
}
|
||||||
if (code.IsNullOrEmpty()) return code;
|
if (code.IsNullOrEmpty()) return code;
|
||||||
string encode = "";
|
string encode = "";
|
||||||
byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(code);
|
byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(code);
|
||||||
@@ -384,6 +388,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (StaticConfig.Decode != null)
|
||||||
|
{
|
||||||
|
return StaticConfig.Decode(code);
|
||||||
|
}
|
||||||
if (code.IsNullOrEmpty()) return code;
|
if (code.IsNullOrEmpty()) return code;
|
||||||
string decode = "";
|
string decode = "";
|
||||||
byte[] bytes = Convert.FromBase64String(code);
|
byte[] bytes = Convert.FromBase64String(code);
|
||||||
@@ -488,24 +496,128 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return Guid.Parse(item.FieldValue);
|
return Guid.Parse(item.FieldValue);
|
||||||
}
|
}
|
||||||
else if (item.CSharpTypeName == "int")
|
else if (item.CSharpTypeName.EqualCase("int"))
|
||||||
{
|
{
|
||||||
return Convert.ToInt32(item.FieldValue);
|
return Convert.ToInt32(item.FieldValue);
|
||||||
}
|
}
|
||||||
else if (item.CSharpTypeName == "long")
|
else if (item.CSharpTypeName .EqualCase("long"))
|
||||||
{
|
{
|
||||||
return Convert.ToInt64(item.FieldValue);
|
return Convert.ToInt64(item.FieldValue);
|
||||||
}
|
}
|
||||||
else if (item.CSharpTypeName == "short")
|
else if (item.CSharpTypeName.EqualCase("short"))
|
||||||
{
|
{
|
||||||
return Convert.ToInt16(item.FieldValue);
|
return Convert.ToInt16(item.FieldValue);
|
||||||
}
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("byte"))
|
||||||
|
{
|
||||||
|
return Convert.ToByte(item.FieldValue);
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase( "uint"))
|
||||||
|
{
|
||||||
|
return Convert.ToUInt32(item.FieldValue);
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase( "ulong"))
|
||||||
|
{
|
||||||
|
return Convert.ToUInt64(item.FieldValue);
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("ushort"))
|
||||||
|
{
|
||||||
|
return Convert.ToUInt16(item.FieldValue);
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase( "uint32"))
|
||||||
|
{
|
||||||
|
return Convert.ToUInt32(item.FieldValue);
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase( "uint64"))
|
||||||
|
{
|
||||||
|
return Convert.ToUInt64(item.FieldValue);
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("uint16"))
|
||||||
|
{
|
||||||
|
return Convert.ToUInt16(item.FieldValue);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return item.FieldValue;
|
return item.FieldValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsNumber(string ctypename)
|
||||||
|
{
|
||||||
|
if (ctypename.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var item = new ConditionalModel()
|
||||||
|
{
|
||||||
|
CSharpTypeName = ctypename,
|
||||||
|
};
|
||||||
|
if (item.CSharpTypeName.EqualCase(UtilConstants.DecType.Name))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase(UtilConstants.DobType.Name))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase(UtilConstants.IntType.Name))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase(UtilConstants.LongType.Name))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase(UtilConstants.ShortType.Name))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("int"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("long"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("short"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("byte"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("uint"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("ulong"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("ushort"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("uint32"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("uint64"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (item.CSharpTypeName.EqualCase("uint16"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get Week Last Day Sun
|
/// Get Week Last Day Sun
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Reference in New Issue
Block a user