This commit is contained in:
grzegorz.russek
2019-07-11 07:46:56 +00:00
parent 0723f4e9b1
commit e9ebf82dd1
7 changed files with 163 additions and 28 deletions

View File

@@ -1,4 +1,3 @@
/* /*
* DynamORM - Dynamic Object-Relational Mapping library. * DynamORM - Dynamic Object-Relational Mapping library.
* Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com) * Copyright (c) 2012-2015, Grzegorz Russek (grzegorz.russek@gmail.com)
@@ -3374,6 +3373,9 @@ namespace DynamORM
/// <summary>Gets the value stored in object.</summary> /// <summary>Gets the value stored in object.</summary>
public object Value { get; internal set; } public object Value { get; internal set; }
/// <summary>Gets the last access time.</summary>
public long Ticks { get; internal set; }
} }
private Dictionary<string, object> _data = new Dictionary<string, object>(); private Dictionary<string, object> _data = new Dictionary<string, object>();
@@ -3405,6 +3407,7 @@ namespace DynamORM
_lastProp.Name = binder.Name; _lastProp.Name = binder.Name;
_lastProp.Value = result; _lastProp.Value = result;
_lastProp.Type = result == null ? typeof(void) : result.GetType(); _lastProp.Type = result == null ? typeof(void) : result.GetType();
_lastProp.Ticks = DateTime.Now.Ticks;
return true; return true;
} }
@@ -3422,6 +3425,7 @@ namespace DynamORM
_lastProp.Name = binder.Name; _lastProp.Name = binder.Name;
_lastProp.Value = value; _lastProp.Value = value;
_lastProp.Type = value == null ? typeof(void) : value.GetType(); _lastProp.Type = value == null ? typeof(void) : value.GetType();
_lastProp.Ticks = DateTime.Now.Ticks;
return true; return true;
} }
@@ -4180,7 +4184,7 @@ namespace DynamORM
}); });
if (method != null) if (method != null)
ret = o.ToString().TryParseDefault<T>(defaultValue, delegate(string v, out T r) ret = o.ToString().TryParseDefault<T>(defaultValue, delegate (string v, out T r)
{ {
r = defaultValue; r = defaultValue;
return (bool)method.Invoke(null, new object[] { v, r }); return (bool)method.Invoke(null, new object[] { v, r });
@@ -4239,7 +4243,7 @@ namespace DynamORM
else if (typeof(T) == typeof(object)) else if (typeof(T) == typeof(object))
ret = (T)o; ret = (T)o;
else if (method != null) else if (method != null)
ret = o.ToString().TryParseDefault<T>(defaultValue, delegate(string v, out T r) ret = o.ToString().TryParseDefault<T>(defaultValue, delegate (string v, out T r)
{ {
r = defaultValue; r = defaultValue;
return (bool)method.Invoke(null, new object[] { v, r }); return (bool)method.Invoke(null, new object[] { v, r });
@@ -6482,7 +6486,8 @@ namespace DynamORM
private DynamicConnection _con; private DynamicConnection _con;
private bool _singleTransaction; private bool _singleTransaction;
private Action _disposed; private Action _disposed;
private bool _operational = false; private bool _isDisposed = false;
private bool _isOperational = false;
/// <summary>Initializes a new instance of the <see cref="DynamicTransaction" /> class.</summary> /// <summary>Initializes a new instance of the <see cref="DynamicTransaction" /> class.</summary>
/// <param name="db">Database connection manager.</param> /// <param name="db">Database connection manager.</param>
@@ -6503,24 +6508,39 @@ namespace DynamORM
if (!_db.TransactionPool.ContainsKey(_con.Connection)) if (!_db.TransactionPool.ContainsKey(_con.Connection))
throw new InvalidOperationException("Can't create transaction using disposed connection."); throw new InvalidOperationException("Can't create transaction using disposed connection.");
else if (_singleTransaction && _db.TransactionPool[_con.Connection].Count > 0) else if (_singleTransaction && _db.TransactionPool[_con.Connection].Count > 0)
_operational = false; {
_isOperational = false;
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "BEGIN TRAN [NON OPERATIONAL]");
}
else else
{ {
if (customParams != null) if (customParams != null)
{ {
MethodInfo mi = _con.Connection.GetType().GetMethods().Where(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == customParams.GetType()).FirstOrDefault(); MethodInfo mi = _con.Connection.GetType().GetMethods().Where(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == customParams.GetType()).FirstOrDefault();
if (mi != null) if (mi != null)
{
_db.TransactionPool[_con.Connection].Push((IDbTransaction)mi.Invoke(_con.Connection, new object[] { customParams, })); _db.TransactionPool[_con.Connection].Push((IDbTransaction)mi.Invoke(_con.Connection, new object[] { customParams, }));
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "BEGIN TRAN [CUSTOM ARGS]");
}
else else
throw new MissingMethodException(string.Format("Method 'BeginTransaction' accepting parameter of type '{0}' in '{1}' not found.", throw new MissingMethodException(string.Format("Method 'BeginTransaction' accepting parameter of type '{0}' in '{1}' not found.",
customParams.GetType().FullName, _con.Connection.GetType().FullName)); customParams.GetType().FullName, _con.Connection.GetType().FullName));
} }
else else
{
_db.TransactionPool[_con.Connection] _db.TransactionPool[_con.Connection]
.Push(il.HasValue ? _con.Connection.BeginTransaction(il.Value) : _con.Connection.BeginTransaction()); .Push(il.HasValue ? _con.Connection.BeginTransaction(il.Value) : _con.Connection.BeginTransaction());
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "BEGIN TRAN");
}
_db.PoolStamp = DateTime.Now.Ticks; _db.PoolStamp = DateTime.Now.Ticks;
_operational = true; _isOperational = true;
} }
} }
} }
@@ -6530,7 +6550,7 @@ namespace DynamORM
{ {
lock (_db.SyncLock) lock (_db.SyncLock)
{ {
if (_operational) if (_isOperational)
{ {
Stack<IDbTransaction> t = _db.TransactionPool.TryGetValue(_con.Connection); Stack<IDbTransaction> t = _db.TransactionPool.TryGetValue(_con.Connection);
@@ -6542,10 +6562,15 @@ namespace DynamORM
trans.Commit(); trans.Commit();
trans.Dispose(); trans.Dispose();
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "COMMIT");
} }
_operational = false; _isOperational = false;
} }
else if (!_isDisposed && _db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "COMMIT [NON OPERATIONAL]");
} }
} }
@@ -6554,7 +6579,7 @@ namespace DynamORM
{ {
lock (_db.SyncLock) lock (_db.SyncLock)
{ {
if (_operational) if (_isOperational)
{ {
Stack<IDbTransaction> t = _db.TransactionPool.TryGetValue(_con.Connection); Stack<IDbTransaction> t = _db.TransactionPool.TryGetValue(_con.Connection);
@@ -6566,10 +6591,15 @@ namespace DynamORM
trans.Rollback(); trans.Rollback();
trans.Dispose(); trans.Dispose();
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "ROLLBACK");
} }
_operational = false; _isOperational = false;
} }
else if (!_isDisposed && _db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "ROLLBACK [NON OPERATIONAL]");
} }
} }
@@ -6588,6 +6618,7 @@ namespace DynamORM
/// freeing, releasing, or resetting unmanaged resources.</summary> /// freeing, releasing, or resetting unmanaged resources.</summary>
public void Dispose() public void Dispose()
{ {
_isDisposed = true;
Rollback(); Rollback();
if (_disposed != null) if (_disposed != null)
@@ -6595,7 +6626,7 @@ namespace DynamORM
} }
/// <summary>Gets a value indicating whether this instance is disposed.</summary> /// <summary>Gets a value indicating whether this instance is disposed.</summary>
public bool IsDisposed { get { return !_operational; } } public bool IsDisposed { get { return !_isOperational; } }
#endregion IExtendedDisposable Members #endregion IExtendedDisposable Members
} }
@@ -13186,6 +13217,36 @@ namespace DynamORM
} }
} }
/// <summary>Exception thrown when mapper fails to set or get a property.</summary>
/// <seealso cref="System.Exception" />
public class DynamicMapperException : Exception
{
/// <summary>Initializes a new instance of the <see cref="DynamicMapperException"/> class.</summary>
public DynamicMapperException()
{
}
/// <summary>Initializes a new instance of the <see cref="DynamicMapperException"/> class.</summary>
/// <param name="message">The message that describes the error.</param>
public DynamicMapperException(string message) : base(message)
{
}
/// <summary>Initializes a new instance of the <see cref="DynamicMapperException"/> class.</summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
public DynamicMapperException(string message, Exception innerException) : base(message, innerException)
{
}
/// <summary>Initializes a new instance of the <see cref="DynamicMapperException"/> class.</summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
protected DynamicMapperException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
/// <summary>Dynamic property invoker.</summary> /// <summary>Dynamic property invoker.</summary>
public class DynamicPropertyInvoker public class DynamicPropertyInvoker
{ {
@@ -13336,9 +13397,9 @@ namespace DynamORM
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new InvalidCastException( throw new DynamicMapperException(
string.Format("Error trying to convert value '{0}' of type '{1}' to value of type '{2}' in object of type '{3}'", string.Format("Error trying to convert and set value '{0}' of type '{1}' to type '{2}' in object of type '{3}'",
(val ?? string.Empty).ToString(), val.GetType(), Type.FullName, dest.GetType().FullName), val == null ? string.Empty : val.ToString(), val.GetType(), Type.FullName, dest.GetType().FullName),
ex); ex);
} }
} }

View File

@@ -22,6 +22,7 @@
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>Full</DebugType> <DebugType>Full</DebugType>
@@ -36,6 +37,7 @@
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<Prefer32Bit>False</Prefer32Bit> <Prefer32Bit>False</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>PdbOnly</DebugType> <DebugType>PdbOnly</DebugType>
@@ -49,6 +51,7 @@
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<Prefer32Bit>False</Prefer32Bit> <Prefer32Bit>False</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> <PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<BaseAddress>4194304</BaseAddress> <BaseAddress>4194304</BaseAddress>
@@ -56,12 +59,15 @@
<RegisterForComInterop>False</RegisterForComInterop> <RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<Prefer32Bit>False</Prefer32Bit> <Prefer32Bit>False</Prefer32Bit>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@@ -112,13 +118,13 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MSTest.TestAdapter"> <PackageReference Include="MSTest.TestAdapter">
<Version>1.2.1</Version> <Version>2.0.0-beta4</Version>
</PackageReference> </PackageReference>
<PackageReference Include="MSTest.TestFramework"> <PackageReference Include="MSTest.TestFramework">
<Version>1.2.1</Version> <Version>2.0.0-beta4</Version>
</PackageReference> </PackageReference>
<PackageReference Include="System.Data.SQLite"> <PackageReference Include="System.Data.SQLite">
<Version>1.0.109.1</Version> <Version>1.0.111</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -101,6 +101,7 @@
<Compile Include="Helpers\UnclassifiedExtensions.cs" /> <Compile Include="Helpers\UnclassifiedExtensions.cs" />
<Compile Include="Mapper\ColumnAttribute.cs" /> <Compile Include="Mapper\ColumnAttribute.cs" />
<Compile Include="Mapper\DynamicMapperCache.cs" /> <Compile Include="Mapper\DynamicMapperCache.cs" />
<Compile Include="Mapper\DynamicMapperException.cs" />
<Compile Include="Mapper\DynamicPropertyInvoker.cs" /> <Compile Include="Mapper\DynamicPropertyInvoker.cs" />
<Compile Include="Mapper\DynamicTypeMap.cs" /> <Compile Include="Mapper\DynamicTypeMap.cs" />
<Compile Include="Mapper\IgnoreAttribute.cs" /> <Compile Include="Mapper\IgnoreAttribute.cs" />

View File

@@ -63,6 +63,9 @@ namespace DynamORM
/// <summary>Gets the value stored in object.</summary> /// <summary>Gets the value stored in object.</summary>
public object Value { get; internal set; } public object Value { get; internal set; }
/// <summary>Gets the last access time.</summary>
public long Ticks { get; internal set; }
} }
private Dictionary<string, object> _data = new Dictionary<string, object>(); private Dictionary<string, object> _data = new Dictionary<string, object>();
@@ -94,6 +97,7 @@ namespace DynamORM
_lastProp.Name = binder.Name; _lastProp.Name = binder.Name;
_lastProp.Value = result; _lastProp.Value = result;
_lastProp.Type = result == null ? typeof(void) : result.GetType(); _lastProp.Type = result == null ? typeof(void) : result.GetType();
_lastProp.Ticks = DateTime.Now.Ticks;
return true; return true;
} }
@@ -111,6 +115,7 @@ namespace DynamORM
_lastProp.Name = binder.Name; _lastProp.Name = binder.Name;
_lastProp.Value = value; _lastProp.Value = value;
_lastProp.Type = value == null ? typeof(void) : value.GetType(); _lastProp.Type = value == null ? typeof(void) : value.GetType();
_lastProp.Ticks = DateTime.Now.Ticks;
return true; return true;
} }

View File

@@ -42,7 +42,8 @@ namespace DynamORM
private DynamicConnection _con; private DynamicConnection _con;
private bool _singleTransaction; private bool _singleTransaction;
private Action _disposed; private Action _disposed;
private bool _operational = false; private bool _isDisposed = false;
private bool _isOperational = false;
/// <summary>Initializes a new instance of the <see cref="DynamicTransaction" /> class.</summary> /// <summary>Initializes a new instance of the <see cref="DynamicTransaction" /> class.</summary>
/// <param name="db">Database connection manager.</param> /// <param name="db">Database connection manager.</param>
@@ -63,24 +64,39 @@ namespace DynamORM
if (!_db.TransactionPool.ContainsKey(_con.Connection)) if (!_db.TransactionPool.ContainsKey(_con.Connection))
throw new InvalidOperationException("Can't create transaction using disposed connection."); throw new InvalidOperationException("Can't create transaction using disposed connection.");
else if (_singleTransaction && _db.TransactionPool[_con.Connection].Count > 0) else if (_singleTransaction && _db.TransactionPool[_con.Connection].Count > 0)
_operational = false; {
_isOperational = false;
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "BEGIN TRAN [NON OPERATIONAL]");
}
else else
{ {
if (customParams != null) if (customParams != null)
{ {
MethodInfo mi = _con.Connection.GetType().GetMethods().Where(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == customParams.GetType()).FirstOrDefault(); MethodInfo mi = _con.Connection.GetType().GetMethods().Where(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == customParams.GetType()).FirstOrDefault();
if (mi != null) if (mi != null)
{
_db.TransactionPool[_con.Connection].Push((IDbTransaction)mi.Invoke(_con.Connection, new object[] { customParams, })); _db.TransactionPool[_con.Connection].Push((IDbTransaction)mi.Invoke(_con.Connection, new object[] { customParams, }));
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "BEGIN TRAN [CUSTOM ARGS]");
}
else else
throw new MissingMethodException(string.Format("Method 'BeginTransaction' accepting parameter of type '{0}' in '{1}' not found.", throw new MissingMethodException(string.Format("Method 'BeginTransaction' accepting parameter of type '{0}' in '{1}' not found.",
customParams.GetType().FullName, _con.Connection.GetType().FullName)); customParams.GetType().FullName, _con.Connection.GetType().FullName));
} }
else else
{
_db.TransactionPool[_con.Connection] _db.TransactionPool[_con.Connection]
.Push(il.HasValue ? _con.Connection.BeginTransaction(il.Value) : _con.Connection.BeginTransaction()); .Push(il.HasValue ? _con.Connection.BeginTransaction(il.Value) : _con.Connection.BeginTransaction());
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "BEGIN TRAN");
}
_db.PoolStamp = DateTime.Now.Ticks; _db.PoolStamp = DateTime.Now.Ticks;
_operational = true; _isOperational = true;
} }
} }
} }
@@ -90,7 +106,7 @@ namespace DynamORM
{ {
lock (_db.SyncLock) lock (_db.SyncLock)
{ {
if (_operational) if (_isOperational)
{ {
Stack<IDbTransaction> t = _db.TransactionPool.TryGetValue(_con.Connection); Stack<IDbTransaction> t = _db.TransactionPool.TryGetValue(_con.Connection);
@@ -102,10 +118,15 @@ namespace DynamORM
trans.Commit(); trans.Commit();
trans.Dispose(); trans.Dispose();
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "COMMIT");
} }
_operational = false; _isOperational = false;
} }
else if (!_isDisposed && _db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "COMMIT [NON OPERATIONAL]");
} }
} }
@@ -114,7 +135,7 @@ namespace DynamORM
{ {
lock (_db.SyncLock) lock (_db.SyncLock)
{ {
if (_operational) if (_isOperational)
{ {
Stack<IDbTransaction> t = _db.TransactionPool.TryGetValue(_con.Connection); Stack<IDbTransaction> t = _db.TransactionPool.TryGetValue(_con.Connection);
@@ -126,10 +147,15 @@ namespace DynamORM
trans.Rollback(); trans.Rollback();
trans.Dispose(); trans.Dispose();
if (_db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "ROLLBACK");
} }
_operational = false; _isOperational = false;
} }
else if (!_isDisposed && _db.DumpCommands && _db.DumpCommandDelegate != null)
_db.DumpCommandDelegate(null, "ROLLBACK [NON OPERATIONAL]");
} }
} }
@@ -148,6 +174,7 @@ namespace DynamORM
/// freeing, releasing, or resetting unmanaged resources.</summary> /// freeing, releasing, or resetting unmanaged resources.</summary>
public void Dispose() public void Dispose()
{ {
_isDisposed = true;
Rollback(); Rollback();
if (_disposed != null) if (_disposed != null)
@@ -155,7 +182,7 @@ namespace DynamORM
} }
/// <summary>Gets a value indicating whether this instance is disposed.</summary> /// <summary>Gets a value indicating whether this instance is disposed.</summary>
public bool IsDisposed { get { return !_operational; } } public bool IsDisposed { get { return !_isOperational; } }
#endregion IExtendedDisposable Members #endregion IExtendedDisposable Members
} }

View File

@@ -0,0 +1,35 @@
using System;
using System.Runtime.Serialization;
namespace DynamORM.Mapper
{
/// <summary>Exception thrown when mapper fails to set or get a property.</summary>
/// <seealso cref="System.Exception" />
public class DynamicMapperException : Exception
{
/// <summary>Initializes a new instance of the <see cref="DynamicMapperException"/> class.</summary>
public DynamicMapperException()
{
}
/// <summary>Initializes a new instance of the <see cref="DynamicMapperException"/> class.</summary>
/// <param name="message">The message that describes the error.</param>
public DynamicMapperException(string message) : base(message)
{
}
/// <summary>Initializes a new instance of the <see cref="DynamicMapperException"/> class.</summary>
/// <param name="message">The error message that explains the reason for the exception.</param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
public DynamicMapperException(string message, Exception innerException) : base(message, innerException)
{
}
/// <summary>Initializes a new instance of the <see cref="DynamicMapperException"/> class.</summary>
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
protected DynamicMapperException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

View File

@@ -186,9 +186,9 @@ namespace DynamORM.Mapper
} }
catch (Exception ex) catch (Exception ex)
{ {
throw new InvalidCastException( throw new DynamicMapperException(
string.Format("Error trying to convert value '{0}' of type '{1}' to value of type '{2}' in object of type '{3}'", string.Format("Error trying to convert and set value '{0}' of type '{1}' to type '{2}' in object of type '{3}'",
(val ?? string.Empty).ToString(), val.GetType(), Type.FullName, dest.GetType().FullName), val == null ? string.Empty : val.ToString(), val.GetType(), Type.FullName, dest.GetType().FullName),
ex); ex);
} }
} }