.Save() method

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 04-Feb-2009 17:31:52   

Hi, this my be a silly question. I just started using llblgen and a new question arises in every step. I apologize if this is answered before.

The .Save() method returns a true or false right. In my entity there is a field that can not be Null. While setting the values for it, i intentionally didnt set the value of a field, that wont accept null, to see what would happen. And i got b"blah blah this field can not be null ..." error.

when does .Save() method return a false? my code was something like this:

UserEntity newUser = new UserEntity(); newUser.FirstName = "first1"; //newUser.LastName = "last1"; (last name can not be null)

if (newUser.Save()) { lblMessage.Text = "save successfull"; } else { lblMessage.Text= "save failed"; }

thanks -shane

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Feb-2009 06:13:13   

Hi Shane,

It returns true if: - There is nothing to save (you didn't modify any field), so nothing happens. - Nothing was wrong. - The authorizers (if you use LLBLGenPro Authorizers) return false. For example, the user is denied to perform some action. - You didn't return false on the possible override methods (UpdateEntity, SaveEntity, etc.).

It returns false if: - For instance, you implement authorizers and the user is denied to perform some actions. - You override some overridable method and for any reason you return false.

An exception is thrown gnerally if a database exception occurs, or a validation rule is broken (when you use LLBLGenPro Validators).

David Elizondo | LLBLGen Support Team