Error when I try update entity

Posts   
 
    
Posts: 8
Joined: 19-Mar-2014
# Posted on: 13-May-2014 12:58:11   

Hi guys !

First of all, I am using MVC 4, .NET 4.5 and LLBL Gen Pro v 3.5 Final. So I am trying update my entity. But I get this error.

During a save action an entity's update action failed. The entity which failed is enclosed

This is my Repository :

            //register is a C# model
            DashboardUserEntity entity = new DashboardUserEntity(register.GlobalID);
            entity.IsDirty = true;
            entity.IsNew = false;
            entity.GlobalId = register.GlobalID;
            entity.AboutMe = register.AboutMe;
            entity.BirthDate = register.BirthDate;
            entity.Sex = register.Sex;
            entity.ProfilePicture = ProfileURL;

            entity.Save();

And my DashUser model:

    public long DashboardID { get; set; }
    public string AboutMe { get; set; }
    public DateTime BirthDate { get; set; }
    public bool Sex { get; set; }
    public string ProfilePicture { get; set; }

So this is clear for you. Do you need more info or code. When I debug my code entity.Save(); line give error.

Thanks guys.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 13-May-2014 21:27:07   

Could you please inspect the generated SQL Command and post it here?

Posts: 8
Joined: 19-Mar-2014
# Posted on: 21-May-2014 20:28:23   

Sorry for delay.

I understand you want sql query like this

UPDATE DashboardUser SET AboutMe = 'About', BirthDate= CURRENT_TIMESTAMP, Sex = 'True',ProfilePicture = 'asd.jpg' Where GlobalID = 80008

And Its working fine.Is it make any sense ?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-May-2014 08:39:35   

A concurrency exception occurs on updates, which is caused by the fact the number of rows affected by the update is 0. This can be caused by:

1) the row isn't there anymore (i.e.: your GlobalID = 80008 doesn't exist) or 2) the rowcounting feature on the sqlserver instance is switched off on the database level. Switch it back on in the connection parameters of the sql server instance. if this is switched on, the db server will report '0' after the update, which suggests the update query failed.

David Elizondo | LLBLGen Support Team
Posts: 8
Joined: 19-Mar-2014
# Posted on: 29-May-2014 20:29:37   

Thanks guys.

It was return 0 and I fixed. It was my bad.