Skip to content

Commit

Permalink
Fixing a SqliteLogger bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuslpm committed Apr 28, 2014
1 parent 91d6108 commit b8c75aa
Show file tree
Hide file tree
Showing 44 changed files with 97 additions and 72 deletions.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
Binary file added CodeProject/LoggingAndProfiling/NLogInExcel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion EntityLite.sln
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EntityLite.ttinclude", "Ent
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodeProject", "CodeProject", "{F926993D-D441-4457-9A74-E1BC8A746B52}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EntityLite", "EntityLite", "{BCEE35A4-CA5B-489E-B1BE-E3AD44F04C81}"
ProjectSection(SolutionItems) = preProject
CodeProject\EntityLite.htm = CodeProject\EntityLite.htm
CodeProject\EntityLite\EntityLite.htm = CodeProject\EntityLite\EntityLite.htm
EndProjectSection
EndProject
Global
Expand Down Expand Up @@ -87,5 +89,6 @@ Global
{0493F652-14B1-45DD-A168-A4686ACBB9D8} = {6ADBA794-C80D-48EE-80F9-41639CF9CF08}
{03CAC007-291D-420D-8E8C-CC9FA92BFEB5} = {0493F652-14B1-45DD-A168-A4686ACBB9D8}
{345D112F-72B2-49C2-907B-40F219FA928C} = {03CAC007-291D-420D-8E8C-CC9FA92BFEB5}
{BCEE35A4-CA5B-489E-B1BE-E3AD44F04C81} = {F926993D-D441-4457-9A74-E1BC8A746B52}
EndGlobalSection
EndGlobal
Binary file modified EntityLite.v12.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion Samples/EntityLite.ttinclude/EntityLite.ttinclude
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<#@ assembly name="Microsoft.CSharp" #>
<#@ assembly name="System.Data" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="$(SolutionDir)packages\EntityLite.Core.1.4.0\lib\net35-client\inercya.EntityLite.dll" #>
<#@ assembly name="$(SolutionDir)packages\EntityLite.Core.1.4.1\lib\net35-client\inercya.EntityLite.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.Data" #>
Expand Down
27 changes: 27 additions & 0 deletions Samples/NLog.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
<targets>
<target xsi:type="AsyncWrapper" name="AsyncFile">
<target
xsi:type="File" name="File"
fileName="${basedir}/NLog.csv"
archiveFileName="${basedir}/NLog.{#}.csv"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="7"
concurrentWrites="true">
<layout xsi:type="CsvLayout" delimiter="Semicolon">
<column name="time" layout="${longdate}" />
<column name="logger" layout="${logger}"/>
<column name="level" layout="${level}"/>
<column name="message" layout="${message}" />
<column name="exception" layout="${exception:format=tostring}" />
</layout>
</target>
</target>
</targets>
<rules>
<logger name="inercya.*" writeTo="AsyncFile" minlevel="Trace" />
</rules>
</nlog>
Binary file modified Samples/Northwind.mdf
Binary file not shown.
Binary file modified Samples/Northwind_log.ldf
Binary file not shown.
22 changes: 22 additions & 0 deletions Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static void Main(string[] args)
RaiseProductPrices2();
HandCraftedSql();
Localization();
WillFail();

Pivot();
}
Expand All @@ -72,6 +73,27 @@ static void Main(string[] args)

}

private static void WillFail()
{
try
{
var od = new OrderDetail
{

OrderId = 1,
ProductId = 11,
UnitPrice = 14,
Quantity = 12

};
ds.OrderDetailRepository.Save(od);
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}


private static void Pivot()
{
Expand Down
3 changes: 3 additions & 0 deletions Samples/Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
<None Include="EntityLite.ttinclude\ProcedureResultSetKind.ttinclude" />
<None Include="EntityLite.ttinclude\ProcedureSetting.ttinclude" />
<None Include="EntityLite.ttinclude\Sequence.ttinclude" />
<None Include="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Northwind.db3">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
4 changes: 2 additions & 2 deletions Samples/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityLite" version="1.4.0" targetFramework="net40" />
<package id="EntityLite.Core" version="1.4.0" targetFramework="net40" />
<package id="EntityLite" version="1.4.1" targetFramework="net40" />
<package id="EntityLite.Core" version="1.4.1" targetFramework="net40" />
<package id="Microsoft.SqlServer.Types" version="10.50.1600.1" targetFramework="net40" />
<package id="MySql.Data" version="6.7.4" targetFramework="net40" />
<package id="NLog" version="2.1.0" targetFramework="net40" />
Expand Down
4 changes: 2 additions & 2 deletions inercya.EntityLite/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ limitations under the License.
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyVersion("1.4.1.0")]
[assembly: AssemblyFileVersion("1.4.1.0")]
70 changes: 20 additions & 50 deletions inercya.EntityLite/CommandLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,61 +42,30 @@ protected AbstractCommand(DataService dataService, bool disposeCommand)
}

protected abstract DbCommand GetCommand();


public int ExecuteNonQuery()
{
return this.ExecuteCommand(getCommand =>
return this.ExecuteCommand( cmd =>
{
DbCommand cmd = null;
try
{
cmd = getCommand();
var returnValue = cmd.ExecuteNonQuery();
SetOutPutParameters(cmd);
return returnValue;
}
finally
{
if (DisposeCommand && cmd != null) cmd.Dispose();
}
var returnValue = cmd.ExecuteNonQuery();
SetOutPutParameters(cmd);
return returnValue;
});
}

public object ExecuteScalar()
{
return this.ExecuteCommand(getCommand =>
return this.ExecuteCommand(cmd =>
{
DbCommand cmd = null;
try
{
cmd = getCommand();
var returnValue = cmd.ExecuteScalar();
SetOutPutParameters(cmd);
return returnValue;
}
finally
{
if (DisposeCommand && cmd != null) cmd.Dispose();
}
var returnValue = cmd.ExecuteScalar();
SetOutPutParameters(cmd);
return returnValue;
});
}

public IDataReader ExecuteReader()
{
return this.ExecuteCommand(getCommand =>
{
DbCommand cmd = null;
try
{
cmd = getCommand();
return cmd.ExecuteReader();
}
finally
{
if (DisposeCommand && cmd != null) cmd.Dispose();
}
});
return this.ExecuteCommand(cmd => cmd.ExecuteReader());
}

protected abstract void SetOutPutParameters(DbCommand command);
Expand All @@ -112,16 +81,13 @@ public IDataReader ExecuteReader()
try
{
int maxRetries = DataService.IsActiveTransaction ? 0 : DataService.MaxRetries;

Func<IDataReader> func = () =>
{
command = GetConfiguredCommand();
return command.ExecuteReader();
};
command = GetConfiguredCommand();
Func<IDataReader> func = () => command.ExecuteReader();
var watch = Stopwatch.StartNew();
var reader = func.ExecuteWithRetries(
maxRetries, DataService.InitialMillisecondsRetryDelay,
(ex, willRetry) => DataService.NotifyErrorOcurred(ex, willRetry));

using (reader)
{
var factory = reader.GetFactory(typeof(T));
Expand Down Expand Up @@ -157,16 +123,16 @@ private DbCommand GetConfiguredCommand()
return command;
}

private T ExecuteCommand<T>(Func<Func<DbCommand>, T> executeCommandFunc)
private T ExecuteCommand<T>(Func<DbCommand, T> executeCommandFunc)
{
DbCommand command = null;
try
{
int maxRetries = DataService.IsActiveTransaction ? 0 : DataService.MaxRetries;

DbCommand command = null;
command = GetConfiguredCommand();
Func<T> func = () =>
{
return executeCommandFunc(() => command = GetConfiguredCommand());
return executeCommandFunc(command);
};
var watch = Stopwatch.StartNew();
var result = func.ExecuteWithRetries(
Expand All @@ -180,6 +146,10 @@ private T ExecuteCommand<T>(Func<Func<DbCommand>, T> executeCommandFunc)
Log.ErrorException("Couldn't execute command", ex);
throw;
}
finally
{
if (command != null && DisposeCommand) command.Dispose();
}
}
}

Expand Down
Binary file added nuget/Core/EntityLite.Core.1.4.1.nupkg
Binary file not shown.
4 changes: 2 additions & 2 deletions nuget/Core/EntityLite.Core.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>EntityLite.Core</id>
<version>1.4.0</version>
<version>1.4.1</version>
<title>i-nercya EntityLite Core</title>
<authors>Jesús López</authors>
<owners>i-nercya intelligent software</owners>
Expand All @@ -11,7 +11,7 @@
A lightweight, database first, micro ORM
</description>
<releaseNotes>
Implementing Query Profiling into a SQLite database
Fixing a bug in SqliteProfier
</releaseNotes>
<summary>
The EntityLite core assembly
Expand Down
2 changes: 1 addition & 1 deletion nuget/Core/Publish.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
%~dp0..\NuGet.exe Update -self
%~dp0..\NuGet.exe Push EntityLite.Core.1.4.0.nupkg
%~dp0..\NuGet.exe Push EntityLite.Core.1.4.1.nupkg
pause
Binary file modified nuget/Core/lib/net35-client/inercya.EntityLite.dll
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions nuget/Generators/EntityLite.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>EntityLite</id>
<version>1.4.0</version>
<version>1.4.1</version>
<title>i-nercya EntityLite</title>
<authors>Jesús López</authors>
<owners>i-nercya intelligent software</owners>
Expand All @@ -11,7 +11,7 @@
A lightweight, database first, micro ORM
</description>
<releaseNotes>
Implementing Query Profiling into a SQLite database
Fixing a bug in SqliteProfier
</releaseNotes>
<summary>
The EntityLite code generators and core library
Expand All @@ -23,7 +23,7 @@
<copyright>Copyright 2013</copyright>
<dependencies>
<group targetFramework="net35-client">
<dependency id="EntityLite.Core" version="[1.4.0]" />
<dependency id="EntityLite.Core" version="[1.4.1]" />
</group>
</dependencies>
<references></references>
Expand Down
2 changes: 1 addition & 1 deletion nuget/Generators/Publish.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
%~dp0..\NuGet.exe Update -self
%~dp0..\NuGet.exe Push EntityLite.1.4.0.nupkg
%~dp0..\NuGet.exe Push EntityLite.1.4.1.nupkg
pause
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<#@ assembly name="Microsoft.CSharp" #>
<#@ assembly name="System.Data" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="$(SolutionDir)packages\EntityLite.Core.1.4.0\lib\net35-client\inercya.EntityLite.dll" #>
<#@ assembly name="$(SolutionDir)packages\EntityLite.Core.1.4.1\lib\net35-client\inercya.EntityLite.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.Data" #>
Expand Down
Binary file added packages/EntityLite.1.4.1/EntityLite.1.4.1.nupkg
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>EntityLite</id>
<version>1.4.0</version>
<version>1.4.1</version>
<title>i-nercya EntityLite</title>
<authors>Jesús López</authors>
<owners>i-nercya intelligent software</owners>
<owners>Jesús López</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<projectUrl>https://nuget.org/packages/EntityLite.Generators</projectUrl>
<iconUrl>http://www.i-nercya.com/EntityLite.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A lightweight, database first, micro ORM</description>
<summary>The EntityLite code generators and core library</summary>
<releaseNotes>Implementing Query Profiling into a SQLite database</releaseNotes>
<releaseNotes>Fixing a bug in SqliteProfier</releaseNotes>
<copyright>Copyright 2013</copyright>
<language>en-US</language>
<tags>Micro-ORM ORM SQL DAL Database SQLServer SQLite MySQL Npgsql Postgres PostgreSQL ORACLE EntityLite</tags>
<dependencies>
<group targetFramework=".NETFramework3.5-Client">
<dependency id="EntityLite.Core" version="[1.4.0]" />
<dependency id="EntityLite.Core" version="[1.4.1]" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<#@ assembly name="Microsoft.CSharp" #>
<#@ assembly name="System.Data" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="$(SolutionDir)packages\EntityLite.Core.1.4.0\lib\net35-client\inercya.EntityLite.dll" #>
<#@ assembly name="$(SolutionDir)packages\EntityLite.Core.1.4.1\lib\net35-client\inercya.EntityLite.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.Data" #>
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>EntityLite.Core</id>
<version>1.4.0</version>
<version>1.4.1</version>
<title>i-nercya EntityLite Core</title>
<authors>Jesús López</authors>
<owners>i-nercya intelligent software</owners>
<owners>Jesús López</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<projectUrl>https://nuget.org/packages/EntityLite.Core</projectUrl>
<iconUrl>http://www.i-nercya.com/EntityLite.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A lightweight, database first, micro ORM</description>
<summary>The EntityLite core assembly</summary>
<releaseNotes>Implementing Query Profiling into a SQLite database</releaseNotes>
<releaseNotes>Fixing a bug in SqliteProfier</releaseNotes>
<copyright>Copyright 2013</copyright>
<language>en-US</language>
<tags>Micro-ORM ORM SQL DAL Database SQLServer SQLite MySQL Npgsql Postgres PostgreSQL ORACLE EntityLite</tags>
Expand Down
Binary file not shown.

0 comments on commit b8c75aa

Please sign in to comment.