Files
2026-07-10 15:25:05 +08:00

81 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace Zhaizj.Framework.ORM.Utils {
internal class SqlUtil {
public static List<String[]> getEntityProperties( String condition ) {
List<String[]> result = new List<String[]>();
String[] arrItem = condition.Split( ' ' );
foreach (String str in arrItem) {
if (str.IndexOf( '.' ) < 0) continue;
String[] arr = getPropertyItems( str );
result.Add( arr );
}
return result;
}
public static String[] getPropertyItems( String str ) {
String[] arr = new string[2];
String key = "";
String val = "";
Boolean valBegin = false;
char[] arrChar = str.ToCharArray();
foreach (char ch in arrChar) {
if( ch == ' ' ) continue;
if (ch == '.') {
valBegin = true;
continue;
}
if (valBegin == false) {
if (isAbcAndNumber( ch ) == false) {
key = "";
continue;
}
key += ch;
}
else {
if (isAbcAndNumber( ch ) == false) {
break;
}
val += ch;
}
}
arr[0] = key;
arr[1] = val;
return arr;
}
private static Boolean isAbcAndNumber( char ch ) {
return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".IndexOf( ch ) >= 0;
}
}
}