Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> ExpressionToApply doesnot reset after field change
 

Pages: 1
Bugs & Issues
ExpressionToApply doesnot reset after field change
Page:1/1 

  Print all messages in this thread  
Poster Message
Rosacek
User



Location:
CZ
Joined on:
18-Mar-2012 18:02:44
Posted:
133 posts
# Posted on: 17-Apr-2016 15:24:48.  
LLBLGEN v4.2.16.311 , Adapter

Hi,
I set field.ExpressionToApply to some function, then save entity.
After that I change fied value by databinding to nothing or to any value and save entity.

I expect that new field value is saved by UPDATE.
But I can see that ExpressionToApply is used again in SQL UPDATE Angry

Is it behavior OK?
I would say that after field value change then field.ExpressionToApply should be set to Nothing automatically.
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8086 posts
# Posted on: 18-Apr-2016 03:11:42.  
Rosacek wrote:
I would say that after field value change then field.ExpressionToApply should be set to Nothing automatically.

No, that is not that obvious. If you are using the same entity instance, you should set ExpressionToApply to null/Nothing.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Rosacek
User



Location:
CZ
Joined on:
18-Mar-2012 18:02:44
Posted:
133 posts
# Posted on: 18-Apr-2016 11:29:43.  
The question was, why LLBL is not doing that automatically after changing field value?
Do you agree taht changing value means I want to save this value into SQL server? Why should I test manually right befeore changing field value if there is ExpressionToApply then set it to nothing?
Does not make sense to me




  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37631 posts
# Posted on: 18-Apr-2016 16:58:59.  
The expression to apply for saving is more of a way to get things into the query system for persistence, so it's mainly meant for: you set it, you use it to execute a query, then you discard the entity. If you keep it around, then you have to clear it manually, as it is what David said: it's ambiguous what to do: clear it always or leave it as is. For its intended use case it's discarded anyway, so we don't clear things for you.

The value in the field is actually ignored when expression to apply is set, setting the field doesn't trigger logic to reset that expression.


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Rosacek
User



Location:
CZ
Joined on:
18-Mar-2012 18:02:44
Posted:
133 posts
# Posted on: 18-Apr-2016 18:18:21.  
Bad news for me Angry

Well, what is the best place to reset ExpressionToApply to nothing?
Override SaveEntity and SaveEntityCollection in DataAdapter and
set there ExpressionToApply=Nothing? Or is there better place?
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14529 posts
# Posted on: 19-Apr-2016 00:39:17.  
Not sure how generalized you want it to be, which will affect the decision to clear the expression in the business logic or the lower layers.

One suggestion would be to use the ValidateEntityBeforeSave in a validator class, to check if the entity.Fields is not new, and then clear the expression.
And then you can decide either to inject this validator into all instances created of this entity type, or just set it in specific locations, either by system wide DI , or by using DI Scopes


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37631 posts
# Posted on: 19-Apr-2016 10:23:47.  
If you want to have it cleared when a value is set in the entity, you can override in a partial class of CommonEntityBase (so it works for all entities):
OnSetValueComplete(fieldIndex)

In there you simply set the ExpressionToApply property of the field on index FieldIndex to null

Alternatively you can clear things in a partial class of DataAccessAdapter and override OnSaveEntityComplete.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Rosacek
User



Location:
CZ
Joined on:
18-Mar-2012 18:02:44
Posted:
133 posts
# Posted on: 19-Apr-2016 10:25:31.  
Yes, this makes sense.
Thanks Regular Smiley


  Top
Pages: 1  


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

Version: 2.1.12172008 Final.