Update ToUnderLine

This commit is contained in:
sunkaixuan 2022-12-10 17:12:49 +08:00
parent eb4a0255e7
commit 0532cd246b

View File

@ -19,7 +19,11 @@ namespace SqlSugar
{ {
public static string ToUnderLine(string str, bool isToUpper = false) public static string ToUnderLine(string str, bool isToUpper = false)
{ {
if (isToUpper) if (str == null || str.Contains("_"))
{
return str;
}
else if (isToUpper)
{ {
return string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString() : x.ToString())).ToUpper(); return string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString() : x.ToString())).ToUpper();
} }