Entity not saving to sql View with instead of trigger

Posts   
 
    
happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 12-May-2015 22:28:59   

LLBL 4.2 - adapter - sql server.

I have a sql view, just some simple joins, and an instead of update trigger. I've manually tested the view with an update statement and the trigger works.

When I call SaveEntity, it returns true but nothing is saved. I have logging on, the entity was marked dirty, and I can see the prior select statements firing, but I did not see any update statement logged after I called SaveEntity.

I have set a primary key for the view based entity and also set it to scope identity.

I am trying to update an existing record, not create a new one.

What am I missing?

happyfirst
User
Posts: 215
Joined: 28-Nov-2008
# Posted on: 12-May-2015 22:32:02   

Jeez, never fails. Moments after posting I finally see the 'allowed actions' dropdown in the designer. Now it works.

So why did you decide to return true for save if it's not allowed?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-May-2015 08:37:41   

happyfirst wrote:

Jeez, never fails. Moments after posting I finally see the 'allowed actions' dropdown in the designer. Now it works.

Good that you figured it out simple_smile

happyfirst wrote:

So why did you decide to return true for save if it's not allowed?

Quoted from the documentation:

Effect of an action executed on an entity which doesn't have the required action Delete / Update Directly and individual Delete methods will report false when an entity is Deleted / Updated directly which doesn't have the Delete / Update action as an allowed action. This is in line with the result of a denied delete/update through an Authorizer. The Save related methods report true when an entity doesn't have the required action in its action combinations. This is also in line with what an Authorizer will result in. So in short it's equal to when an Authorizer denies the action. This also means that saving a modified entity which doesn't have the insert/update action will still open a transaction/connection.

Modified read-only (R/RD/CR/CRD) entities When an entity is passed to an update/save method, and the entity is dirty (changed) but the entity has no Update action defined in its action combination, the entity is ignored for the action. This is equal to an Authorizer denying the action.

As the actions are defined on the mapping it can be an entity is r/w on one database but r/o on another database, the entity itself can't be denying changes. This means a dirty entity can end up in a graph for persistence to a database onto which it has no update/create action defined. To throw exceptions in that case results in a lot of inconvenient code for the user, so the runtime will ignore the entity 'silently' as if it's not there.

David Elizondo | LLBLGen Support Team