Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> JsonConvert.DeserializeObject to populate Llblgen Entity with field from computed column
 

Pages: 1
LLBLGen Pro Runtime Framework
JsonConvert.DeserializeObject to populate Llblgen Entity with field from computed column
Page:1/1 

  Print all messages in this thread  
Poster Message
like2175
User



Location:
Camberley, United Kingdom
Joined on:
27-Mar-2006 16:16:06
Posted:
83 posts
# Posted on: 12-Nov-2019 16:14:01.  
Hi

I am passing LLBLgen Entities to and from a WEBAPI successfully, however I hit a problem when the Entity relates to a SQL table with a computed column.

I have had to remove the ReadOnly flag in the designer to allow the Field that relates to the computed column to be populated by JsonConvert.DeserializeObject With ReadOnly set true, quite sensibly, no value is written to the field.

Now when I try to adapter.SaveEntity({toSave}) I get, quite sensibly again, an ORMQueryExecutionException: 'The column {column)name} cannot be modified because it is either a computed column or... '

Is there any easy solution?

C# Winforms front end
WEB API 2.0 Middle Tier
SQL 2014 back end
LLBLGen 5.2.3
VS 2019.

The following may help for context:
Code:

public async Task<int> SaveAsync(IEntity2 entityToSave, string url)
        {
         var contentMessage = new StringContent(JsonConvert.SerializeObject(entityToSave, _jsonSettingProvider.GetJsonConfiguration()), Encoding.UTF8, "application/json");

            var response = _httpClientWithRetryProvider.Client().PutAsync($@"{url}/Single/", contentMessage).Result;
etc.




Code:

public async Task<T> GetWebApiValueAsync<T>(string url)
        {
            using (var response = _httpClientWithRetryProvider.GetAsync($@"{url}"))
            {

                var result = await response.Content.ReadAsStringAsync();
                if (response.IsSuccessStatusCode)
                {
                    var retVal = JsonConvert.DeserializeObject<T>(result, _jsonSettingProvider.GetJsonConfiguration());
                    return retVal;
                }


Thanks in advance
Graham
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14529 posts
# Posted on: 12-Nov-2019 18:33:26.  
Before saving, set the EntityField.IsChanged property to false, for the compute column field of the entity.

  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.