Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Oracle Driver #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
obj
# Visual Studio artifacts
bin
packages
obj
release
debug
obj/*
bin/*
release/*
debug/*
.svn
*.tmp
*.user
*.suo
*.user
*.vsp
*.csproj.VisualState.xml
*.exe
*.pdb
*.vspscc
*.vssscc
*.Publish.xml
*.cache
*.dgml
packages
packages/*
.nuget
.nuget/*

# NUnit artifacts
TestResult.xml

# Resharper artifacts
_ReSharper.*
*.resharper

# Nupkg artifacts
*.nupkg

# Tests
*.testsettings
*.vsmdi
*.testsettings

# ncrunch
*.ncrunchsolution
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Data;
using System.Data.Common;
using System.Data.OracleClient;
using NHibernate.AdoNet;
using NHibernate.Driver;
using StackExchange.Profiling.NHibernate.Infrastructure;

namespace StackExchange.Profiling.NHibernate.Drivers.Oracle
{
public class MiniProfilerOracle10ClientDriver : OracleClientDriver, IEmbeddedBatcherFactoryProvider
{
public override IDbCommand CreateCommand()
{
var command = base.CreateCommand();

if (MiniProfiler.Current != null)
command = new ProfiledGenericDbCommand<OracleCommand>((DbCommand)command, MiniProfiler.Current);

return command;
}

Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass
{
get { return typeof(OracleDataClientBatchingBatcherFactory); }
}
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
using System;
using System.Data;
using System.Data.Common;
using NHibernate.AdoNet;
using NHibernate.Driver;
using StackExchange.Profiling.NHibernate.Infrastructure;

namespace StackExchange.Profiling.NHibernate.Drivers
{
public class MiniProfilerSql2008ClientDriver : Sql2008ClientDriver, IEmbeddedBatcherFactoryProvider
{
public override IDbCommand CreateCommand()
{
var command = base.CreateCommand();

if (MiniProfiler.Current != null)
command = new ProfiledSqlDbCommand((DbCommand)command, MiniProfiler.Current);

return command;
}

Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass
{
get { return typeof(ProfiledSqlClientBatchingBatcherFactory); }
}
}
using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using NHibernate.AdoNet;
using NHibernate.Driver;
using StackExchange.Profiling.NHibernate.Infrastructure;

namespace StackExchange.Profiling.NHibernate.Drivers.SQLServer
{
public class MiniProfilerSql2008ClientDriver : Sql2008ClientDriver, IEmbeddedBatcherFactoryProvider
{
public override IDbCommand CreateCommand()
{
var command = base.CreateCommand();

if (MiniProfiler.Current != null)
command = new ProfiledGenericDbCommand<SqlCommand>((DbCommand)command, MiniProfiler.Current);

return command;
}

Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass
{
get { return typeof(ProfiledSqlClientBatchingBatcherFactory); }
}
}
}
22 changes: 22 additions & 0 deletions MiniProfiler.NHibernate/Infrastructure/ProfiledGenericDbCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Data.Common;
using StackExchange.Profiling.Data;

namespace StackExchange.Profiling.NHibernate.Infrastructure
{
internal class ProfiledGenericDbCommand<T> : ProfiledDbCommand
where T : DbCommand
{
private readonly T _command;

public ProfiledGenericDbCommand(DbCommand command, IDbProfiler profiler)
: base(command, null, profiler)
{
_command = (T)command;
}

public T Command
{
get { return _command; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public override void AddToBatch(IExpectation expectation)
.AppendLine(lineWithParameters);
}

var update = batchUpdate as ProfiledSqlDbCommand;
var update = batchUpdate as ProfiledGenericDbCommand<SqlCommand>;
if (update != null)
{
_currentBatch.Append(update.SqlCommand);
_currentBatch.Append(update.Command);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Data.Common;
using System;
using System.Data.Common;
using System.Data.SqlClient;
using StackExchange.Profiling.Data;

namespace StackExchange.Profiling.NHibernate.Infrastructure
{
[Obsolete]
internal class ProfiledSqlDbCommand : ProfiledDbCommand
{
private readonly SqlCommand _sqlCommand;
Expand Down
6 changes: 5 additions & 1 deletion MiniProfiler.NHibernate/MiniProfiler.NHibernate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.OracleClient" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Drivers\MiniProfilerSql2008ClientDriver.cs" />
<Compile Include="Drivers\SQLServer\MiniProfilerSql2008ClientDriver.cs" />
<Compile Include="Drivers\Oracle\MiniProfilerOracle10ClientDriver.cs" />
<Compile Include="Infrastructure\ProfiledGenericDbCommand.cs" />
<Compile Include="Infrastructure\ProfiledSqlClientBatchingBatcher.cs" />
<Compile Include="Infrastructure\ProfiledSqlClientBatchingBatcherFactory.cs" />
<Compile Include="Infrastructure\ProfiledSqlDbCommand.cs" />
Expand All @@ -60,6 +63,7 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down