Skip to content

Commit

Permalink
Merge pull request #12 from carloscs/master
Browse files Browse the repository at this point in the history
Add support for Informix databases
  • Loading branch information
rvrn22 authored Apr 14, 2020
2 parents 8043cfa + 903ffdc commit b6fd218
Show file tree
Hide file tree
Showing 13 changed files with 571 additions and 8 deletions.
Binary file added Lib/IBM.Data.DB.Provider/IBM.Data.DB2.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion NMG.App/App.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions NMG.App/ConnectionDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ private string GetDefaultConnectionStringForServerType(ServerType serverType)
return StringConstants.SQLITE_CONN_STR_TEMPLATE;
case ServerType.Sybase:
return StringConstants.SYBASE_CONN_STR_TEMPLATE;
case ServerType.Informix:
return StringConstants.INFORMIX_CONN_STR_TEMPLATE;
case ServerType.Ingres:
return StringConstants.INGRES_CONN_STR_TEMPLATE;
case ServerType.CUBRID:
Expand Down
19 changes: 16 additions & 3 deletions NMG.App/NMG.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@
<StartupObject>NHibernateMappingGenerator.Program</StartupObject>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;MONO</DefineConstants>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand All @@ -60,6 +62,9 @@
<Reference Include="FastColoredTextBox">
<HintPath>..\Lib\FastColoredTextBox\FastColoredTextBox.dll</HintPath>
</Reference>
<Reference Include="IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208, processorArchitecture=AMD64">
<HintPath>..\packages\IBM.Data.DB.Provider.11.1.4040.4\lib\net451\x64\IBM.Data.DB2.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.ConnectionUI">
<HintPath>..\Lib\Microsoft.Data.ConnectionUI\Microsoft.Data.ConnectionUI.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -119,6 +124,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand Down Expand Up @@ -157,6 +163,13 @@
<Folder Include="Resources\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\IBM.Data.DB.Provider.11.1.4040.4\build\IBM.Data.DB.Provider.targets" Condition="Exists('..\packages\IBM.Data.DB.Provider.11.1.4040.4\build\IBM.Data.DB.Provider.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\IBM.Data.DB.Provider.11.1.4040.4\build\IBM.Data.DB.Provider.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IBM.Data.DB.Provider.11.1.4040.4\build\IBM.Data.DB.Provider.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
4 changes: 4 additions & 0 deletions NMG.App/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="IBM.Data.DB.Provider" version="11.1.4040.4" targetFramework="net46" />
</packages>
17 changes: 17 additions & 0 deletions NMG.Core/DataTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@ public Type MapFromDBType(ServerType serverType, string dataType, int? dataLengt
return MapFromOracleDBType(dataType, dataLength, dataPrecision, dataScale);
case ServerType.MySQL:
return MapFromMySqlDBType(dataType, dataLength, dataPrecision, dataScale);
case ServerType.SQLite:
return MapFromSqliteDbType(dataType, dataLength, dataPrecision, dataScale);
case ServerType.PostgreSQL:
return MapFromPostgreDBType(dataType, dataLength, dataPrecision, dataScale);
case ServerType.Sybase:
return MapFromSqlServerDBType(dataType, dataLength, dataPrecision, dataScale);
case ServerType.Informix:
return MapFromInformixDbType(dataType, dataLength, dataPrecision, dataScale);
case ServerType.Ingres:
return MapFromIngresDbType(dataType, dataLength, dataPrecision, dataScale);
case ServerType.CUBRID:
Expand Down Expand Up @@ -156,6 +160,19 @@ private Type MapFromSqliteDbType(string dataType, int? dataLength, int? dataPrec
return MapFromDBType(dataType, dataLength, dataPrecision, dataScale);
}

private Type MapFromInformixDbType(string dataType, int? dataLength, int? dataPrecision, int? dataScale)
{
switch (dataType)
{
case "Serial":
return typeof(int);
case "Serial8":
return typeof(long);
default:
return MapFromDBType(dataType, dataLength, dataPrecision, dataScale);
}
}

/// <summary>
/// CUBRID implementation of the data types NHIbernate mappings
/// http://www.cubrid.org
Expand Down
1 change: 1 addition & 0 deletions NMG.Core/Domain/ServerType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public enum ServerType
MySQL,
SQLite,
Sybase,
Informix,
Ingres,
CUBRID
}
Expand Down
4 changes: 4 additions & 0 deletions NMG.Core/MetadataFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ public static IMetadataReader GetReader(ServerType serverType, string connection
return new OracleMetadataReader(connectionStr);
case ServerType.SqlServer:
return new SqlServerMetadataReader(connectionStr);
case ServerType.PostgreSQL:
return new NpgsqlMetadataReader(connectionStr);
case ServerType.MySQL:
return new MysqlMetadataReader(connectionStr);
case ServerType.SQLite:
return new SqliteMetadataReader(connectionStr);
case ServerType.Sybase:
return new SybaseMetadataReader(connectionStr);
case ServerType.Informix:
return new InformixMetadataReader(connectionStr);
case ServerType.Ingres:
return new IngresMetadataReader(connectionStr);
case ServerType.CUBRID:
Expand Down
19 changes: 17 additions & 2 deletions NMG.Core/NMG.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -41,7 +43,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand All @@ -54,6 +56,9 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="IBM.Data.DB2, Version=9.7.4.4, Culture=neutral, PublicKeyToken=7c307b91aa13d208, processorArchitecture=AMD64">
<HintPath>..\packages\IBM.Data.DB.Provider.11.1.4040.4\lib\net451\x64\IBM.Data.DB2.dll</HintPath>
</Reference>
<Reference Include="Ingres.Client, Version=2.1.0.0, Culture=neutral, PublicKeyToken=363043b363d069c5, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Lib\Ingres .NET Data Provider\Ingres.Client.dll</HintPath>
Expand Down Expand Up @@ -121,6 +126,7 @@
<Compile Include="Reader\NpgsqlMetadataReader.cs" />
<Compile Include="Reader\OracleConstraintType.cs" />
<Compile Include="Reader\OracleMetadataReader.cs" />
<Compile Include="Reader\InformixMetadataReader.cs" />
<Compile Include="Reader\SqliteMetadataReader.cs" />
<Compile Include="Reader\SqlServerConstraintType.cs" />
<Compile Include="Reader\SqlServerMetadataReader.cs" />
Expand Down Expand Up @@ -164,5 +170,14 @@
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup />
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="..\packages\IBM.Data.DB.Provider.11.1.4040.4\build\IBM.Data.DB.Provider.targets" Condition="Exists('..\packages\IBM.Data.DB.Provider.11.1.4040.4\build\IBM.Data.DB.Provider.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\IBM.Data.DB.Provider.11.1.4040.4\build\IBM.Data.DB.Provider.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IBM.Data.DB.Provider.11.1.4040.4\build\IBM.Data.DB.Provider.targets'))" />
</Target>
</Project>
Loading

0 comments on commit b6fd218

Please sign in to comment.