igor-tkachev/bltoolkit — Issue #61: Enum mapping to char not working
Author: NetTecture
Created: 2011-10-26 07:32:43+00:00
State: open

Given the following enum:

public enum WorkflowRunStateType
{
[MapValue('S')]
InstanceData,

[MapValue('M')]
InstanceMetaData
}

The following query:

xxx.Where(x => x.Id == runId && x.Entry == WorkflowRunStateType.InstanceMetaData).First();

runs into a conversion exception:

public static Int32 ToInt32(String p) { return p == null? Configuration.NullableValues.Int32 : Int32.Parse(p);

The call stack is:

System.FormatException was unhandled by user code
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at BLToolkit.Common.Convert.ToInt32(String p) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Common\Convert.generated.cs:line 1466
at BLToolkit.Common.Convert.ToInt32(Object p) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Common\Convert.generated.cs:line 1570
at BLToolkit.Mapping.MappingSchema.ConvertToInt32(Object value) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Mapping\MappingSchema.cs:line 218
at BLToolkit.Data.DataProvider.OdpDataProvider.OdpMappingSchema.ConvertToInt32(Object value) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Data\DataProvider\OdpDataProvider.cs:line 694
at BLToolkit.Mapping.MappingSchema.ConvertChangeType(Object value, Type conversionType, Boolean isNullable) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Mapping\MappingSchema.cs:line 941
at BLToolkit.Mapping.MappingSchema.ConvertChangeType(Object value, Type conversionType) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Mapping\MappingSchema.cs:line 810
at BLToolkit.Data.DataProvider.OdpDataProvider.OdpMappingSchema.ConvertChangeType(Object value, Type conversionType) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Data\DataProvider\OdpDataProvider.cs:line 1119
at BLToolkit.Mapping.MemberMapper.MapFrom(Object value, MapMemberInfo mapInfo) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Mapping\MemberMapper.cs:line 716
at BLToolkit.Mapping.MemberMapper.MapFrom(Object value) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Mapping\MemberMapper.cs:line 657
at BLToolkit.Mapping.DefaultMemberMapper.SetValue(Object o, Object value) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Mapping\DefaultMemberMapper.cs:line 17
at BLToolkit.Mapping.ObjectMapper.SetValue(Object o, Int32 index, Object value) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Mapping\ObjectMapper.cs:line 653
at BLToolkit.Mapping.ValueMapping.DefaultValueMapper.Map(IMapDataSource source, Object sourceObject, Int32 sourceIndex, IMapDataDestination dest, Object destObject, Int32 destIndex) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Mapping\ValueMapping.cs:line 26
at BLToolkit.Data.Linq.Query`1.MapDataReaderToObject(Type destObjectType, IDataContext dataContext, IDataReader dataReader, Int32 slotNumber) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Data\Linq\Query.cs:line 530
at lambda_method(Closure , Query`1 , QueryContext , IDataContext , IDataReader , MappingSchema , Expression , Object[] )
at BLToolkit.Data.Linq.Query`1.d__3a.MoveNext() in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Data\Linq\Query.cs:line 395
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
at BLToolkit.Data.Linq.Query`1.b__4a(QueryContext ctx, IDataContextInfo db, Expression expr, Object[] ps) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Data\Linq\Query.cs:line 640
at BLToolkit.Data.Linq.Table`1.System.Linq.IQueryProvider.Execute[TResult](Expression expression) in D:\Work\GloRi\trunk\vs\BlToolkit\Source\Data\Linq\TableT.cs:line 179
at System.Linq.Queryable.First[TSource](IQueryable`1 source)
at Rwe.Glori.Runtime.Workflow.Persistence.InstanceStoreIo.LoadInstance(Guid instanceId, IDictionary`2& instanceData, IDictionary`2& instanceMetadata) in D:\Work\GloRi\trunk\vs\Rwe.Glori\Rwe.Glori.Runtime.Workflow\Persistence\InstanceStoreIo.cs:line 100
at Rwe.Glori.Runtime.Workflow.Persistence.WorkflowInstanceStore.SharedLoadWorkflow(InstancePersistenceContext context, Guid instanceId) in D:\Work\GloRi\trunk\vs\Rwe.Glori\Rwe.Glori.Runtime.Workflow\Persistence\WorkflowInstanceStore.cs:line 102
at Rwe.Glori.Runtime.Workflow.Persistence.WorkflowInstanceStore.ProcessLoadWorkflow(InstancePersistenceContext context, LoadWorkflowCommand command) in D:\Work\GloRi\trunk\vs\Rwe.Glori\Rwe.Glori.Runtime.Workflow\Persistence\WorkflowInstanceStore.cs:line 80
at Rwe.Glori.Runtime.Workflow.Persistence.WorkflowInstanceStore.TryCommand(InstancePersistenceContext context, InstancePersistenceCommand command, TimeSpan timeout) in D:\Work\GloRi\trunk\vs\Rwe.Glori\Rwe.Glori.Runtime.Workflow\Persistence\WorkflowInstanceStore.cs:line 53
at System.Runtime.DurableInstancing.InstancePersistenceContext.ExecuteAsyncResult.RunLoopCore(Boolean synchronous)
at System.Runtime.DurableInstancing.InstancePersistenceContext.ExecuteAsyncResult..ctor(InstanceHandle initialInstanceHandle, InstancePersistenceCommand command, Transaction transaction, TimeSpan timeout)
InnerException:

it seems that the MapValue attribute gets ignored and it tries to convert the "base numeric value" of the enum, instead of the char that should be replacing it.