From c7b63ef4741bd7f05b32424157288ee677a5914f Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Sun, 15 Dec 2019 13:04:08 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E8=A7=A3=E5=86=B3=20vb.net=20=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E6=97=A0=E6=B3=95=E8=A7=A3=E6=9E=90=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E6=AF=94=E8=BE=83=EF=BC=9B#140?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Examples/test_vb/Program.vb | 26 +++++++++++++++++++ Examples/test_vb/test_vb.vbproj | 13 ++++++++++ FreeSql.sln | 15 +++++++++++ FreeSql/Internal/CommonExpression.cs | 14 ++++++++++ .../OdbcGBaseAdo/OdbcGBaseConnectionPool.cs | 2 ++ 5 files changed, 70 insertions(+) create mode 100644 Examples/test_vb/Program.vb create mode 100644 Examples/test_vb/test_vb.vbproj diff --git a/Examples/test_vb/Program.vb b/Examples/test_vb/Program.vb new file mode 100644 index 00000000..d0eb32f3 --- /dev/null +++ b/Examples/test_vb/Program.vb @@ -0,0 +1,26 @@ +Imports System + +Module Program + Sub Main(args As String()) + Console.WriteLine("Hello World!") + + Dim fsql = New FreeSql.FreeSqlBuilder() _ + .UseConnectionString(FreeSql.DataType.Sqlite, "data source=testvb.db") _ + .UseAutoSyncStructure(True) _ + .UseMonitorCommand(Sub(cmd) Trace.WriteLine(cmd.CommandText)) _ + .Build() + + REM Microsoft.VisualBasic.CompilerServices.Operators.CompareString() + Dim List1 = fsql.Select(Of Testvb).Where(Function(a) a.Id = 100).ToList() + Dim List2 = fsql.Select(Of Testvb).Where(Function(a) a.Title = "xxx").ToList() + Dim List3 = fsql.Select(Of Testvb).Where(Function(a) a.Title <> "xxx").ToList() + + fsql.Dispose() + End Sub +End Module + +Class Testvb + Property Id As Integer + Property Title As String +End Class + diff --git a/Examples/test_vb/test_vb.vbproj b/Examples/test_vb/test_vb.vbproj new file mode 100644 index 00000000..6c715f78 --- /dev/null +++ b/Examples/test_vb/test_vb.vbproj @@ -0,0 +1,13 @@ + + + + Exe + test_vb + netcoreapp3.1 + + + + + + + diff --git a/FreeSql.sln b/FreeSql.sln index b5273404..211de198 100644 --- a/FreeSql.sln +++ b/FreeSql.sln @@ -68,6 +68,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "orm_vs_net40", "Examples\or EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FreeSql.Generator", "Extensions\FreeSql.Generator\FreeSql.Generator.csproj", "{6A3A4470-7DF7-411B-AAD7-755D7A9DB5A4}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "test_vb", "Examples\test_vb\test_vb.vbproj", "{0A2206B1-1D34-45F4-B028-E3C5D6F02295}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -402,6 +404,18 @@ Global {6A3A4470-7DF7-411B-AAD7-755D7A9DB5A4}.Release|x64.Build.0 = Release|Any CPU {6A3A4470-7DF7-411B-AAD7-755D7A9DB5A4}.Release|x86.ActiveCfg = Release|Any CPU {6A3A4470-7DF7-411B-AAD7-755D7A9DB5A4}.Release|x86.Build.0 = Release|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Debug|x64.ActiveCfg = Debug|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Debug|x64.Build.0 = Debug|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Debug|x86.ActiveCfg = Debug|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Debug|x86.Build.0 = Debug|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Release|Any CPU.Build.0 = Release|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Release|x64.ActiveCfg = Release|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Release|x64.Build.0 = Release|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Release|x86.ActiveCfg = Release|Any CPU + {0A2206B1-1D34-45F4-B028-E3C5D6F02295}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -426,6 +440,7 @@ Global {C57444BA-8BF7-4790-A864-7F237123219B} = {2A381C57-2697-427B-9F10-55DA11FD02E4} {1674BCE3-EEB4-4003-A2A7-06F51EFAEA23} = {94C8A78D-AA15-47B2-A348-530CD86BFC1B} {6A3A4470-7DF7-411B-AAD7-755D7A9DB5A4} = {4A92E8A6-9A6D-41A1-9CDA-DE10899648AA} + {0A2206B1-1D34-45F4-B028-E3C5D6F02295} = {94C8A78D-AA15-47B2-A348-530CD86BFC1B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {089687FD-5D25-40AB-BA8A-A10D1E137F98} diff --git a/FreeSql/Internal/CommonExpression.cs b/FreeSql/Internal/CommonExpression.cs index e7d7bd56..10af2539 100644 --- a/FreeSql/Internal/CommonExpression.cs +++ b/FreeSql/Internal/CommonExpression.cs @@ -417,6 +417,20 @@ namespace FreeSql.Internal } public string ExpressionBinary(string oper, Expression leftExp, Expression rightExp, ExpTSC tsc) { + if (leftExp.NodeType == ExpressionType.Call && + rightExp.NodeType == ExpressionType.Constant && + new[] { "=", "<>" }.Contains(oper)) + { + var leftExpCall = leftExp as MethodCallExpression; + //vb 语法,将字符串比较转换为了 CompareString + if (leftExpCall.Method.Name == "CompareString" && + leftExpCall.Method.DeclaringType?.FullName == "Microsoft.VisualBasic.CompilerServices.Operators" && + leftExpCall.Arguments.Count == 3 && + leftExpCall.Arguments[2].Type == typeof(bool) && + rightExp.Type == typeof(int) && + (int)(rightExp as ConstantExpression).Value == 0) + return ExpressionBinary(oper, leftExpCall.Arguments[0], leftExpCall.Arguments[1], tsc); + } switch (oper) { case "OR": diff --git a/Providers/FreeSql.Provider.Odbc/GBase/OdbcGBaseAdo/OdbcGBaseConnectionPool.cs b/Providers/FreeSql.Provider.Odbc/GBase/OdbcGBaseAdo/OdbcGBaseConnectionPool.cs index e9c6fae6..b22e01e5 100644 --- a/Providers/FreeSql.Provider.Odbc/GBase/OdbcGBaseAdo/OdbcGBaseConnectionPool.cs +++ b/Providers/FreeSql.Provider.Odbc/GBase/OdbcGBaseAdo/OdbcGBaseConnectionPool.cs @@ -9,6 +9,8 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +//jdbc:gbasedbt-sqli://192.168.164.10:9088/gbasedb:GBASEDBTSERVER=gbaseserver;DB_LOCALE=zh_CN.GB18030-2000;CLIENT_LOCALE=zh_CN.GB18030-2000;NEWCODESET=GB18030,GB18030-2000,5488; + namespace FreeSql.Odbc.GBase {