Reassign Entity Field Value

Posts   
 
    
oq
User
Posts: 6
Joined: 17-Jun-2009
# Posted on: 17-Jun-2009 18:50:16   

I've come across a situation which isn't clear to me. The following code works:

            application.Billing.Bank.AccountNumber = "1";
            application.Billing.Bank.RoutingNumber = "1";

But the following code does not work:

            application.Billing.Bank.AccountNumber =
                cryptographer.EncryptSymmetric(application.Billing.Bank.AccountNumber);
            application.Billing.Bank.RoutingNumber =
                cryptographer.EncryptSymmetric(application.Billing.Bank.RoutingNumber);

I've made sure the database fields hold sufficient characters to avoid truncation exceptions. The entity fields AccountNumber and RoutingNumber already contain a value prior to the above field operations. The root entity application is hydrated from the active Session in an ASP.NET MVC application.

I receive no exceptions. What am I missing here?

Thanks!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Jun-2009 02:04:09   

What "doesn't work" means? (the assignation fails, doesn't generate sql for that field, the entity isn't saved)

Whah LLBLGen version and runtime library version are you using? (http://llblgen.com/TinyForum/Messages.aspx?ThreadID=7725)

David Elizondo | LLBLGen Support Team
oq
User
Posts: 6
Joined: 17-Jun-2009
# Posted on: 18-Jun-2009 02:18:33   

I'm using v2.6.

I believe I know why it isn't working. The value "1" is assigned to the field however the encrypted value is not being assigned due to validation checks in the validator. The validator is used via dependency injection.

What made this difficult to realize though is there is no exception thrown. My validator doesn't throw an exception, rather it logs the error via the SetEntityFieldError method.

Ultimately what I was trying to do was set a value on a field. Then further downstream in my workflow, I wanted to encrypt the value then finally save the entity. The validator will fail for the encrypted value and I neglected to realize that.