UpdateEntitiesDirectly and automatically setting property value

Posts   
 
    
Findev
User
Posts: 107
Joined: 08-Dec-2014
# Posted on: 07-Aug-2024 19:08:02   

Hi,

for some entities I have DateModified column and a corresponding property which is set to "UTC now" in OnBeforeEntitySave, what would be (if any) analogous but for when UpdateEntitiesDirectly is used so that I don't have to manually assign the value every time.

Thank you!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 08-Aug-2024 08:48:15   

The UpdateEntitiesDirectly method is virtual, so you could override it and first check the values in the entity specified, or you could use the event OnUpdateEntitiesDirectly, but that's a little later in the pipeline as it already has created the query (so you need to change the parameter values in that case).

Alternatively you could override OnSetValue in a partial class of the entity, and check the value there if it's a datetime and if so convert it to a UTC datetime And yet another alternative is to define a typeconverter on the datetime field which does the datetime <->UTC datetime conversion for you. This type converter is built into the framework (and shipped with the designer) so it might be the best option (and you don't need to convert the value manually)

Frans Bouma | Lead developer LLBLGen Pro