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

Error - Update of fields is not allowed

2 Answers 83 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Winson
Top achievements
Rank 1
Winson asked on 10 Apr 2014, 07:49 PM
Hi,

I got this error when I tried to update an existing record, please see below:

Server Error in '/' Application.

The update of field 'ProjectName.Data.OA.Contact._organization' is not allowed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Telerik.OpenAccess.Exceptions.InvalidOperationException: The update of field 'ProjectName.Data.OA.Contact._organization' is not allowed.

Source Error:

Line 86: set
Line 87: {
Line 88: this._organization = value;
Line 89: }
Line 90: }
Source File: c:\Projects\ProjectName\Project.Data.OA\Entities\Contact.generated.cs Line: 88

Stack Trace:

[InvalidOperationException: The update of field 'ProjectName.Data.OA.Contact._organization' is not allowed.]
Telerik.OpenAccess.SPI.Backends.ThrowException(Exception e) +28
OpenAccessRuntime.ExceptionWrapper.Throw() +42
OpenAccessRuntime.DataObjects.PCStateMan.handleException(Exception x) +106
OpenAccessRuntime.DataObjects.PCStateMan.setStringFieldImp(PersistenceCapable _pc, FieldMetaData fmd, String currentValue, String newValue) +353
OpenAccessRuntime.DataObjects.PCStateMan.SetStringField(PersistenceCapable _pc, Int32 field, String currentValue, String newValue) +227
ProjectName.Data.OA.Contact.OpenAccessEnhancedSet_organization(Contact owner, String value) +97
ProjectName.Data.OA.Contact.set_Organization(String value) in c:\Projects\DotNet\ProjectName.V2
\ProjectName.Data.OA\Entities\Contact.generated.cs:88
 ProjectName.Web.Controllers.AccountController.ChangePwd(LocalPasswordModel form) in c:\Projects\DotNet\ProjectName.V2\ProjectName.Web\Controllers\AccountController.cs:258
lambda_method(Closure , ControllerBase , Object[] ) +180
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +211
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +48
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +57
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +43
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9633216
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

My code is someting like below:

Contact contact = _dbContext.Contacts.FirstOrDefault(x => x.Email == uc.Session.ContactId);

contact.Organization = "test";

_contactService.Update(contact);

and it throw error on the line of contact.Organization = "test";

please help!

2 Answers, 1 is accepted

Sort by
0
Winson
Top achievements
Rank 1
answered on 10 Apr 2014, 09:56 PM
Just throw some thoughts of mine to make it clearer. It is strange that the error happens on the set value.

private string _organization;
public virtual string Organization
{
get
{
return this._organization;
}
set
{
this._organization = value;
}
}

Is it some setting somewhere to block this value set?

Thanks,
0
Ralph Waldenmaier
Telerik team
answered on 11 Apr 2014, 03:22 PM
Hello Winson,
You can receive such errors in case you have specified the DataAccessKindAttribute as 'ReadOnly'. Please see this link for details. 
To fix it, please review the setting for the particular field and set it to 'ReadWrite'.

I hope this information is helpful for you.
Do come back in case you need further information.

Regards,
Ralph Waldenmaier
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
General Discussions
Asked by
Winson
Top achievements
Rank 1
Answers by
Winson
Top achievements
Rank 1
Ralph Waldenmaier
Telerik team
Share this question
or