This is a migrated thread and some comments may be shown as answers.

Telerik.OpenAccess.OpenAccessException on save changes

3 Answers 172 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gagandeep
Top achievements
Rank 1
Gagandeep asked on 06 Nov 2015, 12:16 PM

Greetings, I am facing a strange issue. I have class properties which are mapped with enum and for database I have a taken char field. Setup seems correct however the enum mapped properties are throwing exception on SaveChanges().

private char _encodingType;

public AssetFontEncodingType EncodingType
        {
            get
            { return (AssetFontEncodingType)_encodingType;}
   set
            {
                _encodingType = (char)value;}
}

private char _embedOption;

public EmbedOptionEncodingType
        {
            get
            { return (EmbedOptionEncodingType)_ embedOption;}
   set
            {
                _ embedOption = (char)value;}
}

Mapping : 

assetFontConfig.HasProperty(x => x.EncodingType).ToColumn("encoding_type").HasFieldName("_encodingType").HasColumnType("character");
 assetFontConfig.HasProperty(x => x.EmbedOption).ToColumn("embed_option").HasFieldName("_embedOption").HasColumnType("character");
​Any help will be appreciated. 

 

Exception Details

An exception of type 'Telerik.OpenAccess.OpenAccessException' occurred in Telerik.OpenAccess.Runtime.dll but was not handled in user code
Additional information: Access to unfilled state field : class=Aleyant.eDocBuilder.Data.Entities.AssetFont no=3 stateField=_encodingType managedField=_encodingType stack=
   at OpenAccessRuntime.common.GenericState.ComplainAboutUnfilledStateFieldAccess(Int32 stateFieldNo)
   at OpenAccessRuntime.common.GenericState.GetField[T](Int32 stateFieldNo)
   at OpenAccessRuntime.DataObjects.PCStateMan.GetFieldImp[T](PersistenceCapable pc, FieldMetaData fmd)
   at OpenAccessRuntime.DataObjects.PCStateMan.GetField[T](PersistenceCapable pc, Int32 field, T currentValue)
   at Aleyant.eDocBuilder.Data.Entities.AssetFont.OpenAccessEnhancedGet_encodingType(AssetFont owner)
   at Aleyant.eDocBuilder.Data.Entities.AssetFont.get_EncodingType()
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at Xunit.Sdk.ArgumentFormatter.<>c__DisplayClassc.<>c__DisplayClass10.<FormatComplexValue>b__5()
   at Xunit.Sdk.ArgumentFormatter.WrapAndGetFormattedValue(Func`1 getter, Int32 depth)
   at Xunit.Sdk.ArgumentFormatter.<>c__DisplayClassc.<FormatComplexValue>b__4(PropertyInfo p)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.<ConcatIterator>d__1`1.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
   at System.Linq.Enumerable.<TakeIterator>d__1`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Xunit.Sdk.ArgumentFormatter.FormatComplexValue(Object value, Int32 depth, Type type)
   at Xunit.Sdk.ArgumentFormatter.Format(Object value, Int32 depth)
   at Xunit.Sdk.AssertActualExpectedException.ConvertToString(Object value)
   at Xunit.Sdk.AssertActualExpectedException..ctor(Object expected, Object actual, String userMessage, String expectedTitle, String actualTitle)
   at Xunit.Assert.Same(Object expected, Object actual)
   at Aleyant.eDocBuilder.Test.DataTest.AssetFontTest.AddAssetFont_OneToOne_Relation()
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClassc.<<InvokeTestMethodAsync>b__9>d__e.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClassc.<InvokeTestMethodAsync>b__9()
   at Xunit.Sdk.ExecutionTimer.<AggregateAsync>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction)
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClassc.<InvokeTestMethodAsync>b__8()
   at Xunit.Sdk.ExceptionAggregator.<RunAsync>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code)
   at Xunit.Sdk.TestInvoker`1.<InvokeTestMethodAsync>d__17.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestInvoker`1.InvokeTestMethodAsync(Object testClassInstance)
   at Xunit.Sdk.TestInvoker`1.<<RunAsync>b__0>d__4.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestInvoker`1.<RunAsync>b__0()
   at Xunit.Sdk.ExceptionAggregator.<RunAsync>d__3`1.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.ExceptionAggregator.RunAsync[T](Func`1 code)
   at Xunit.Sdk.TestInvoker`1.RunAsync()
   at Xunit.Sdk.XunitTestRunner.<InvokeTestMethodAsync>d__6.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.XunitTestRunner.InvokeTestMethodAsync(ExceptionAggregator aggregator)
   at Xunit.Sdk.XunitTestRunner.<InvokeTestAsync>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.XunitTestRunner.InvokeTestAsync(ExceptionAggregator aggregator)
   at Xunit.Sdk.TestRunner`1.<>c__DisplayClass3.<RunAsync>b__1()
   at Xunit.Sdk.ExceptionAggregator.<RunAsync>d__3`1.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.ExceptionAggregator.RunAsync[T](Func`1 code)
   at Xunit.Sdk.TestRunner`1.<RunAsync>d__5.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestRunner`1.RunAsync()
   at Xunit.Sdk.XunitTestCaseRunner.RunTestAsync()
   at Xunit.Sdk.TestCaseRunner`1.<RunAsync>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestCaseRunner`1.RunAsync()
   at Xunit.Sdk.XunitTestCase.RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, Object[] constructorArguments, xceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
   at Xunit.Sdk.XunitTestMethodRunner.RunTestCaseAsync(IXunitTestCase testCase)
   at Xunit.Sdk.TestMethodRunner`1.<RunTestCasesAsync>d__4.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestMethodRunner`1.RunTestCasesAsync()
   at Xunit.Sdk.TestMethodRunner`1.<RunAsync>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestMethodRunner`1.RunAsync()
   at Xunit.Sdk.XunitTestClassRunner.RunTestMethodAsync(ITestMethod testMethod, IReflectionMethodInfo method, IEnumerable`1 testCases, Object[] onstructorArguments)
   at Xunit.Sdk.TestClassRunner`1.<RunTestMethodsAsync>d__9.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestClassRunner`1.RunTestMethodsAsync()
   at Xunit.Sdk.TestClassRunner`1.<RunAsync>d__2.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
  at Xunit.Sdk.TestClassRunner`1.RunAsync()
   at Xunit.Sdk.XunitTestCollectionRunner.RunTestClassAsync(ITestClass testClass, IReflectionTypeInfo class, IEnumerable`1 testCases)
   at Xunit.Sdk.TestCollectionRunner`1.<RunTestClassesAsync>d__7.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestCollectionRunner`1.RunTestClassesAsync()
   at Xunit.Sdk.TestCollectionRunner`1.<RunAsync>d__0.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at Xunit.Sdk.TestCollectionRunner`1.RunAsync()
   at Xunit.Sdk.XunitTestAssemblyRunner.RunTestCollectionAsync(IMessageBus messageBus, ITestCollection testCollection, IEnumerable`1 testCases, CancellationTokenSource cancellationTokenSource)
   at Xunit.Sdk.XunitTestAssemblyRunner.<>c__DisplayClassb.<>c__DisplayClassd.<RunTestCollectionsAsync>b__2()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.SynchronizationContextTaskScheduler.PostCallback(Object obj)
   at Xunit.Sdk.MaxConcurrencySyncContext.<>c__DisplayClass3.<WorkerThreadProc>b__2(Object _)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at Xunit.Sdk.MaxConcurrencySyncContext.WorkerThreadProc()
   at Xunit.Sdk.XunitWorkerThread.<>c__DisplayClass2.<.ctor>b__0()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()​

3 Answers, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 11 Nov 2015, 12:03 PM
Hello Gagandeep,

Unfortunately there is a limitation in Telerik Data Access that you can only map a columns of integer types to enum properties. For more information how enum properties are supported you could refer to this documentation article.

I hope that helps.

Regards,
Boris Georgiev
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
0
Gagandeep
Top achievements
Rank 1
answered on 16 Nov 2015, 07:51 AM
Well, I really doubt. The way I am using, mapping of char field with enum is working without any issue with other tables’ columns. This is the only table class causing an issue. I narrowed down the root cause a bit. This is an AssetFont table having one to one relation with Asset table. If I remove association mapping of both tables, enum mapping starts working somehow. It seems some issue is occurring when the object become managed object after calling SaveChanges(). 
0
Boris Georgiev
Telerik team
answered on 19 Nov 2015, 07:12 AM
Hello Gagandeep,

Based on our test suit, Telerik Data Access officially supports only column of type integer mapped to enum properties. Another column types could also be mapped to enum properties, but there's no guarantee that the mapping will work properly during runtime.

Regards,
Boris Georgiev
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
Getting Started
Asked by
Gagandeep
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
Gagandeep
Top achievements
Rank 1
Share this question
or