Skip to content

Commit 127427b

Browse files
committed
Added support for Dialect 1 in EFCore.
Before you start using the DBContext you need to set the Dialect to 1 like InterBaseSql.EntityFrameworkCore.InterBase.Storage.Internal.IBSqlGenerationHelper.Dialect = 1; This will tell the SqlGeneratorHelper to not quote identify things.
1 parent eef670d commit 127427b

File tree

10 files changed

+67
-9
lines changed

10 files changed

+67
-9
lines changed

NETProvider/Demos/EntityCoreExample2/EFCore101.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
</ItemGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="InterBaseSql.Data.InterBaseClient" Version="7.13.6" />
27-
<PackageReference Include="InterBaseSql.EntityFrameworkCore.InterBase" Version="7.13.6" />
26+
<PackageReference Include="InterBaseSql.Data.InterBaseClient" Version="7.13.7" />
27+
<PackageReference Include="InterBaseSql.EntityFrameworkCore.InterBase" Version="7.13.7" />
2828
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.11">
2929
<PrivateAssets>all</PrivateAssets>
3030
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

NETProvider/Demos/EntityCoreExample2/EmployeeForm.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public partial class EmployeeForm : Form
99
public EmployeeForm()
1010
{
1111
InitializeComponent();
12+
// This is necessary when working with a dialect 1 DB. Setting the dialect must be done before using the DbContext.
13+
InterBaseSql.EntityFrameworkCore.InterBase.Storage.Internal.IBSqlGenerationHelper.Dialect = 1;
1214
}
1315

1416
private void Form1_Load(object sender, EventArgs e)

NETProvider/Demos/EntityCoreExample2/MyEmployeeConnectionContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
3232
if (!optionsBuilder.IsConfigured)
3333
{
3434
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
35-
optionsBuilder.UseInterBase("data source=localhost;initial catalog=Employee;user id=sysdba;password=masterkey");
35+
optionsBuilder.UseInterBase("data source=localhost;initial catalog=Employee;user id=sysdba;password=masterkey;dialect=1");
3636
}
3737
}
3838

NETProvider/Demos/EntityCoreExample2/MyEmployeeUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public long GetNextSequenceValue(string genName)
1111
Database.GetDbConnection().Open();
1212
cmd.CommandText = "SELECT gen_id(" + genName + ", 1) from rdb$database";
1313
var obj = cmd.ExecuteScalar();
14-
return (long)obj;
14+
return Convert.ToInt64(obj);
1515
}
1616
}
1717
}
Binary file not shown.

NETProvider/Provider/src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<DebugType>portable</DebugType>
66
</PropertyGroup>
77
<PropertyGroup>
8-
<VersionPrefix>7.13.6</VersionPrefix>
8+
<VersionPrefix>7.13.7</VersionPrefix>
99
<VersionSuffix></VersionSuffix>
1010
<Company>Embarcadero</Company>
1111
<Product>NETProvider</Product>

NETProvider/Provider/src/InterBaseSql.Data.InterBaseClient/Embarcadero.Data.InterBaseClient.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
<Authors>Embarcadero</Authors>
2323
<Company>Embarcadero</Company>
2424
<PackageIcon></PackageIcon>
25-
<AssemblyVersion>7.13.6.0</AssemblyVersion>
26-
<FileVersion>7.13.6.0</FileVersion>
27-
<Version>7.13.6</Version>
25+
<AssemblyVersion>7.13.7.0</AssemblyVersion>
26+
<FileVersion>7.13.7.0</FileVersion>
27+
<Version>7.13.7</Version>
2828
</PropertyGroup>
2929
<PropertyGroup Condition="'$(Configuration)'=='Release'">
3030
<DefineConstants>TRACE</DefineConstants>

NETProvider/Provider/src/InterBaseSql.EntityFrameworkCore.InterBase/Storage/Internal/Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#Changes for 7.13.7
2+
3+
## IBSqlGeneratorHelper
4+
* Added a static variable called Dialect. It defaults to 3, but when you are working with a Dialcet 1 DB you need to change that static variable to 1.
5+
* Overrode DelimitIdentifier, DelimitIdentifier and DelimitIdentifier to now use the new Dialect variable to determine if the identifier should be double quoted or not.
6+
17
#Changes for 7.13.6 (updated for EFCore 6.0 and to Fb 9.x)
28

39
## added IBDateOnlyTypeMapping.cs, IBRelationalTransaction.cs, IBTimeOnlyTypeMapping.cs, IBTransactionFactory.cs, and IRelationalIBTransaction.cs

NETProvider/Provider/src/InterBaseSql.EntityFrameworkCore.InterBase/Storage/Internal/IBSqlGenerationHelper.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@
1919
//$Authors = Jiri Cincura ([email protected])
2020

2121
using System;
22+
using System.Collections.Generic;
23+
using System.Diagnostics.CodeAnalysis;
2224
using System.Text;
25+
using Microsoft.EntityFrameworkCore.Infrastructure;
26+
using Microsoft.EntityFrameworkCore.Diagnostics;
2327
using Microsoft.EntityFrameworkCore.Storage;
28+
using Microsoft.EntityFrameworkCore.Migrations;
2429

2530
namespace InterBaseSql.EntityFrameworkCore.InterBase.Storage.Internal;
2631

2732
public class IBSqlGenerationHelper : RelationalSqlGenerationHelper, IIBSqlGenerationHelper
2833
{
34+
public static int Dialect = 3;
2935

3036
public IBSqlGenerationHelper(RelationalSqlGenerationHelperDependencies dependencies)
3137
: base(dependencies)
@@ -65,4 +71,48 @@ static void EnsureStringLiteralQueryTypeLength(int length)
6571
if (length > IBTypeMappingSource.UnicodeVarcharMaxSize)
6672
throw new ArgumentOutOfRangeException(nameof(length));
6773
}
74+
75+
public static string NotEmpty([NotNull] string? value, string parameterName)
76+
{
77+
if (value is null)
78+
{
79+
NotEmpty(parameterName, nameof(parameterName));
80+
81+
throw new ArgumentNullException(parameterName);
82+
}
83+
84+
if (value.Trim().Length == 0)
85+
{
86+
NotEmpty(parameterName, nameof(parameterName));
87+
88+
throw new ArgumentException(AbstractionsStrings.ArgumentIsEmpty(parameterName));
89+
}
90+
91+
return value;
92+
}
93+
public override string DelimitIdentifier(string identifier)
94+
{
95+
if (Dialect == 3)
96+
return $"\"{EscapeIdentifier(NotEmpty(identifier, nameof(identifier)))}\"";
97+
else
98+
return $"{EscapeIdentifier(NotEmpty(identifier, nameof(identifier)))}";
99+
}
100+
101+
public override void DelimitIdentifier(StringBuilder builder, string identifier)
102+
{
103+
NotEmpty(identifier, nameof(identifier));
104+
105+
if (Dialect == 3)
106+
{
107+
builder.Append('"');
108+
EscapeIdentifier(builder, identifier);
109+
builder.Append('"');
110+
}
111+
else
112+
EscapeIdentifier(builder, identifier);
113+
}
114+
115+
public override string DelimitIdentifier(string name, string? schema)
116+
=> DelimitIdentifier(NotEmpty(name, nameof(name)));
117+
68118
}

NETProvider/Provider/src/Perf/Perf.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
</ItemGroup>
2020

2121
<ItemGroup Condition="$(Configuration.EndsWith('NuGet'))">
22-
<PackageReference Include="InterBaseSql.Data.InterBaseClient" Version="7.13.6" />
22+
<PackageReference Include="InterBaseSql.Data.InterBaseClient" Version="7.13.7" />
2323
</ItemGroup>
2424
</Project>

0 commit comments

Comments
 (0)