Skip to content

Commit

Permalink
OK, so we can't support parameter discovery for ODBC
Browse files Browse the repository at this point in the history
  • Loading branch information
tsahi committed Dec 26, 2020
1 parent 27baef3 commit 03a1e0c
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 9 deletions.
15 changes: 15 additions & 0 deletions source/Src/Data.Odbc/Data.Odbc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,19 @@
<PackagePath></PackagePath>
</Content>
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
22 changes: 13 additions & 9 deletions source/Src/Data.Odbc/OdbcDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,26 @@ public OdbcDatabase(string connectionString) : base(connectionString, OdbcFactor
/// the Parameters collection of the specified <see cref="DbCommand"/> object.
/// </summary>
/// <param name="discoveryCommand">The <see cref="DbCommand"/> to do the discovery.</param>
/// <exception cref="InvalidCastException"><paramref name="discoveryCommand"/> is not an <see cref="OdbcCommand"/>.</exception>
/// <exception cref="InvalidOperationException">The underlying ODBC provider does not support returning stored
/// procedure parameter information, the command text is not a valid stored procedure name, or the CommandType
/// specified was not <see cref="CommandType.StoredProcedure" />.</exception>
/// <exception cref="NotSupportedException">Always</exception>
/// <remarks>While <see cref="OdbcCommandBuilder"/> supports deriving parameters, we don't know
/// which specific database will be used, what are it's parameter discovery capabilities are,
/// and other differences. So we can't support deriving parameters automatically.</remarks>
protected override void DeriveParameters(DbCommand discoveryCommand)
{
OdbcCommandBuilder.DeriveParameters((OdbcCommand)discoveryCommand);
throw new NotSupportedException(Properties.Resources.ExceptionParameterDiscoveryNotSupportedOnOdbcDatabase);
//To execute a procedure in ODBC you have to name it as "{ Call procName(?,?,?,?) }"
//in the CommandText. But in this syntax, DeriveParameters doesn't work.
//to derive parameters, you have to give just the procedure name in CommandText, but then
//the ExecuteScalar (for example) doesn't work, complaining a parameter is missing.
}

/// <summary>
/// Determines whether the database provider supports parameter discovery. This depends on the underlying
/// ODBC provider.
/// Determines whether the database provider supports parameter discovery.
/// </summary>
/// <value>Returns <b>true</b>, but you should consult the documentation for the underlying ODBC provider.</value>
/// <value>Returns <b>false</b></value>
/// <remarks>Parameter discovery is not supported for ODBC drivers.</remarks>
/// <seealso cref="DeriveParameters(DbCommand)"/>
public override bool SupportsParemeterDiscovery => true;
public override bool SupportsParemeterDiscovery => false;

/// <inheritdoc/>
protected override void SetUpRowUpdatedEvent(DbDataAdapter adapter)
Expand Down
72 changes: 72 additions & 0 deletions source/Src/Data.Odbc/Properties/Resources.Designer.cs

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

123 changes: 123 additions & 0 deletions source/Src/Data.Odbc/Properties/Resources.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ExceptionParameterDiscoveryNotSupportedOnOdbcDatabase" xml:space="preserve">
<value>Parameter discovery is not supported for connections using OdbcDatabase. You must specify the parameters explicitly, or configure the connection to use a type deriving from Database that supports parameter discovery.</value>
</data>
</root>

0 comments on commit 03a1e0c

Please sign in to comment.