Commit f14cb2a2 authored by Helgi Hafþórsson's avatar Helgi Hafþórsson
Browse files

Combined into single project. Added comments.

parent 5254a8fa
......@@ -5,16 +5,12 @@ VisualStudioVersion = 15.0.26430.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marsonsoft.Database", "src\Marsonsoft.Database\Marsonsoft.Database.csproj", "{5A8FB352-10B9-4EB2-9297-49C9A66A65CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marsonsoft.Database.Oracle", "src\Marsonsoft.Database.Oracle\Marsonsoft.Database.Oracle.csproj", "{B421453E-9709-491B-BF25-7B64017DB17A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{871C6815-F7D6-4747-8B65-F39063EF1DBF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{22873875-9BB7-423E-9B7B-E8565A69D525}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marsonsoft.Database.Tests", "test\Marsonsoft.Database.Tests\Marsonsoft.Database.Tests.csproj", "{7D9B2CBD-DB01-4EE6-9743-68B0590D844D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marsonsoft.Database.MySql", "src\Marsonsoft.Database.MySql\Marsonsoft.Database.MySql.csproj", "{1D5D70B3-364D-4625-AD79-C5BFD08AA9ED}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "codeAnalysis", "codeAnalysis", "{F452B515-F5E6-4393-B7A1-07EF1308E75E}"
ProjectSection(SolutionItems) = preProject
codeAnalysis\MarsonsoftRecommended.ruleset = codeAnalysis\MarsonsoftRecommended.ruleset
......@@ -30,26 +26,16 @@ Global
{5A8FB352-10B9-4EB2-9297-49C9A66A65CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A8FB352-10B9-4EB2-9297-49C9A66A65CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A8FB352-10B9-4EB2-9297-49C9A66A65CE}.Release|Any CPU.Build.0 = Release|Any CPU
{B421453E-9709-491B-BF25-7B64017DB17A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B421453E-9709-491B-BF25-7B64017DB17A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B421453E-9709-491B-BF25-7B64017DB17A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B421453E-9709-491B-BF25-7B64017DB17A}.Release|Any CPU.Build.0 = Release|Any CPU
{7D9B2CBD-DB01-4EE6-9743-68B0590D844D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D9B2CBD-DB01-4EE6-9743-68B0590D844D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D9B2CBD-DB01-4EE6-9743-68B0590D844D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D9B2CBD-DB01-4EE6-9743-68B0590D844D}.Release|Any CPU.Build.0 = Release|Any CPU
{1D5D70B3-364D-4625-AD79-C5BFD08AA9ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D5D70B3-364D-4625-AD79-C5BFD08AA9ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D5D70B3-364D-4625-AD79-C5BFD08AA9ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D5D70B3-364D-4625-AD79-C5BFD08AA9ED}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5A8FB352-10B9-4EB2-9297-49C9A66A65CE} = {871C6815-F7D6-4747-8B65-F39063EF1DBF}
{B421453E-9709-491B-BF25-7B64017DB17A} = {871C6815-F7D6-4747-8B65-F39063EF1DBF}
{7D9B2CBD-DB01-4EE6-9743-68B0590D844D} = {22873875-9BB7-423E-9B7B-E8565A69D525}
{1D5D70B3-364D-4625-AD79-C5BFD08AA9ED} = {871C6815-F7D6-4747-8B65-F39063EF1DBF}
EndGlobalSection
EndGlobal
......@@ -45,13 +45,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataEnvironment.cs" />
<Compile Include="DataEnvironmentProviderExtensions.cs" />
<Compile Include="DbExceptionExtensions.cs" />
<Compile Include="MySqlExceptionNumber.cs" />
<Compile Include="MySqlTextValidator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SqlFactory.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Marsonsoft.Database\Marsonsoft.Database.csproj">
......
namespace Marsonsoft.Database.MySql
{
public class SqlFactory : SqlFactoryAnsi92
{
protected override string QuoteIdentifier(string identifier)
{
return "`" + identifier + "`";
}
}
}
......@@ -45,18 +45,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdapterFactory.cs" />
<Compile Include="DataEnvironment.cs" />
<Compile Include="DataEnvironmentProviderExtensions.cs" />
<Compile Include="DbCommandExtensions.cs" />
<Compile Include="DbConnectionExtensions.cs" />
<Compile Include="DbExceptionExtensions.cs" />
<Compile Include="IAdapter.cs" />
<Compile Include="LazyType.cs" />
<Compile Include="ManagedAdapter.cs" />
<Compile Include="NativeAdapter.cs" />
<Compile Include="OracleExceptionNumber.cs" />
<Compile Include="OracleTextValidator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
......
......@@ -4,7 +4,7 @@ namespace Marsonsoft.Database
{
/// <summary>
/// Contains extension methods for the <see cref="IDbConnection"/> interface.
/// </summary>
/// </summary>
public static class DbConnectionExtensions
{
/// <summary>
......@@ -12,7 +12,7 @@ namespace Marsonsoft.Database
/// </summary>
/// <param name="connection">The connection to which the command belongs.</param>
/// <param name="cmdText">The command text.</param>
/// <returns>A new instance of the <see cref="DbCommand"/> class.</returns>
/// <returns>A new instance of the <see cref="IDbCommand"/> class.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]
public static IDbCommand CreateCommand(this IDbConnection connection, string cmdText)
{
......
......@@ -4,7 +4,7 @@ using System.Data;
namespace Marsonsoft.Database
{
/// <summary>
/// Represents a provider of <see cref="DbConnection"/> objects.
/// Represents a provider of <see cref="IDbConnection"/> objects.
/// </summary>
public interface IConnectionProvider
{
......@@ -14,7 +14,7 @@ namespace Marsonsoft.Database
event EventHandler<ConnectionEventArgs> ConnectionOpened;
/// <summary>
/// Creates and open a new object implementing <see cref="DbConnection"/>, based on the default connection string for this provider.
/// Creates and open a new object implementing <see cref="IDbConnection"/>, based on the default connection string for this provider.
/// </summary>
/// <returns>An instance of <see cref="System.Data.IDbConnection"/>.</returns>
IDbConnection OpenConnection();
......
......@@ -5,19 +5,37 @@
/// </summary>
public interface ISqlFactory
{
/// <summary>
/// Returns a valid SQL identifier from the specified argument.
/// </summary>
/// <param name="name">The name to create an identifier from.</param>
/// <returns>A valid SQL identifier.</returns>
/// <summary>
/// Gets or sets a value controlling if and how identifiers created by the class implementing this interface
/// are quoted.
/// </summary>
IdentifierQuoting IdentifierQuoting { get; set; }
/// <summary>
/// Returns the specified name as an identifier based on the rules set in <see cref="IdentifierQuoting"/>.
/// </summary>
/// <remarks>
/// Examples:
/// <p>customer_id => "customer_id" (Oracle)</p>
/// <p>customer_id => `customer_id` (MySQL)</p>
/// <p>customer_id => [customer_id] (SQL Server)</p>
/// </remarks>
/// <param name="name">The name to represent as an SQL identifier.</param>
/// <returns>The <paramref name="name"/> as an SQL identifier.</returns>
string Identifier(string name);
/// <summary>
/// Returns a valid SQL identifier for the specified table name.
/// </summary>
/// <param name="tableName">The table name to create an SQL identifier for.</param>
/// <returns>A valid SQL identifier (or identifiers) for the specified table name.</returns>
string Identifier(TableName tableName);
/// <summary>
/// Returns the specified tble name as an identifier based on the rules set in <see cref="IdentifierQuoting"/>.
/// </summary>
/// <remarks>
/// Examples (when <see cref="IdentifierQuoting"/> is <see cref="IdentifierQuoting.Always"/>):
/// <p>my_schema.my_table => "my_schema"."my_table" (Oracle)</p>
/// <p>my_schema.my_table => `my_schema`.`my_table` (MySQL)</p>
/// <p>my_schema.my_table => [my_schema].[my_table] (SQL Server)</p>
/// </remarks>
/// <param name="tableName">The table name to represent as an SQL identifier.</param>
/// <returns>The <paramref name="tableName"/> as an SQL identifier.</returns>
string Identifier(TableName tableName);
/// <summary>
/// Returns a valid SQL literal representation of the specified value.
......@@ -25,12 +43,5 @@
/// <param name="value">The value to get a literal for.</param>
/// <returns>A valid SQL literal.</returns>
string Literal(object value);
/// <summary>
/// Gets or sets a value controlling if and how identifiers created by the class implementing this interface
/// are quoted.
/// </summary>
IdentifierQuoting IdentifierQuoting { get; set; }
}
}
......@@ -61,6 +61,24 @@
<Compile Include="IdentifierQuoting.cs" />
<Compile Include="ISqlFactory.cs" />
<Compile Include="ITextValidator.cs" />
<Compile Include="MySql\DataEnvironment.cs" />
<Compile Include="MySql\DataEnvironmentProviderExtensions.cs" />
<Compile Include="MySql\DbExceptionExtensions.cs" />
<Compile Include="MySql\MySqlExceptionNumber.cs" />
<Compile Include="MySql\MySqlTextValidator.cs" />
<Compile Include="MySql\SqlFactory.cs" />
<Compile Include="Oracle\AdapterFactory.cs" />
<Compile Include="Oracle\DataEnvironment.cs" />
<Compile Include="Oracle\DataEnvironmentProviderExtensions.cs" />
<Compile Include="Oracle\DbCommandExtensions.cs" />
<Compile Include="Oracle\DbConnectionExtensions.cs" />
<Compile Include="Oracle\DbExceptionExtensions.cs" />
<Compile Include="Oracle\IAdapter.cs" />
<Compile Include="Oracle\LazyType.cs" />
<Compile Include="Oracle\ManagedAdapter.cs" />
<Compile Include="Oracle\NativeAdapter.cs" />
<Compile Include="Oracle\OracleExceptionNumber.cs" />
<Compile Include="Oracle\OracleTextValidator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProviderSupportAttribute.cs" />
<Compile Include="SqlFactoryAnsi92.cs" />
......
......@@ -2,8 +2,15 @@
namespace Marsonsoft.Database.MySql
{
/// <summary>
/// Contains extensions methods for the <see cref="DataEnvironmentProvider"/> class.
/// </summary>
public static class DataEnvironmentProviderExtensions
{
/// <summary>
/// Adds the <see cref="MySql.DataEnvironment"/> to the data environment provider's list of environments.
/// </summary>
/// <param name="dataEnvironmentProvider">The <see cref="DataEnvironmentProvider"/>.</param>
public static void AddMySql(this DataEnvironmentProvider dataEnvironmentProvider)
{
try
......
using System;
namespace Marsonsoft.Database.MySql
{
/// <summary>
/// Implements the <see cref="ISqlFactory"/> interface for the SQL dialect used by MySQL.
/// </summary>
public class SqlFactory : SqlFactoryAnsi92
{
/// <summary>
/// Returnes the specified name as a quoted identifier.
/// </summary>
/// <param name="name">The name to quote.</param>
/// <returns><paramref name="name"/> as a quoted identifier.</returns>
/// <exception cref="ArgumentNullException">name</exception>
protected override string QuoteIdentifier(string name)
{
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
return "`" + name + "`";
}
}
}
......@@ -2,8 +2,15 @@
namespace Marsonsoft.Database.Oracle
{
/// <summary>
/// Contains extensions methods for the <see cref="DataEnvironmentProvider"/> class.
/// </summary>
public static class DataEnvironmentProviderExtensions
{
/// <summary>
/// Adds the <see cref="Oracle.DataEnvironment"/> to the data environment provider's list of environments.
/// </summary>
/// <param name="dataEnvironmentProvider">The <see cref="DataEnvironmentProvider"/>.</param>
public static void AddOracle(this DataEnvironmentProvider dataEnvironmentProvider)
{
try
......
......@@ -15,7 +15,7 @@ namespace Marsonsoft.Database.Oracle
/// <param name="cmdText">The command text.</param>
/// <param name="commandType">The command type.</param>
/// <param name="bindByName"><c>true</c> to bind parameters of the command by their name, <c>false</c> otherwise.</param>
/// <returns>A new instance of the <see cref="DbCommand"/> class.</returns>
/// <returns>A new instance of the <see cref="IDbCommand"/> class.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]
public static IDbCommand CreateCommand(this IDbConnection connection, string cmdText, CommandType commandType, bool bindByName)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment