mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-01 18:59:35 +08:00
Update .net
This commit is contained in:
parent
6a5f3333db
commit
087dcefe1d
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="ExpressionsToSql\Subquery\SubTemplate.cs" />
|
||||
<Compile Include="ExpressionsToSql\Subquery\SubqueryableN.cs" />
|
||||
<Compile Include="Infrastructure\StaticConfig.cs" />
|
||||
<Compile Include="Interface\IFastBuilder.cs" />
|
||||
<Compile Include="Interface\IFastest.cs" />
|
||||
<Compile Include="OnlyNet\OracleFastBuilder.cs" />
|
||||
|
@ -344,6 +344,10 @@ namespace SqlSugar
|
||||
|
||||
public static string EncodeBase64(string code)
|
||||
{
|
||||
if (StaticConfig.Encode != null)
|
||||
{
|
||||
return StaticConfig.Encode(code);
|
||||
}
|
||||
if (code.IsNullOrEmpty()) return code;
|
||||
string encode = "";
|
||||
byte[] bytes = Encoding.GetEncoding("utf-8").GetBytes(code);
|
||||
@ -384,6 +388,10 @@ namespace SqlSugar
|
||||
{
|
||||
try
|
||||
{
|
||||
if (StaticConfig.Decode != null)
|
||||
{
|
||||
return StaticConfig.Decode(code);
|
||||
}
|
||||
if (code.IsNullOrEmpty()) return code;
|
||||
string decode = "";
|
||||
byte[] bytes = Convert.FromBase64String(code);
|
||||
@ -488,24 +496,128 @@ namespace SqlSugar
|
||||
{
|
||||
return Guid.Parse(item.FieldValue);
|
||||
}
|
||||
else if (item.CSharpTypeName == "int")
|
||||
else if (item.CSharpTypeName.EqualCase("int"))
|
||||
{
|
||||
return Convert.ToInt32(item.FieldValue);
|
||||
}
|
||||
else if (item.CSharpTypeName == "long")
|
||||
else if (item.CSharpTypeName .EqualCase("long"))
|
||||
{
|
||||
return Convert.ToInt64(item.FieldValue);
|
||||
}
|
||||
else if (item.CSharpTypeName == "short")
|
||||
else if (item.CSharpTypeName.EqualCase("short"))
|
||||
{
|
||||
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
|
||||
{
|
||||
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>
|
||||
/// Get Week Last Day Sun
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user