Update an entity direclty

Posts   
 
    
usus avatar
usus
User
Posts: 27
Joined: 07-Sep-2006
# Posted on: 05-Dec-2006 14:48:37   

I am trying to update an entity directly as follows

        ServisEntity servis = new ServisEntity();
        try
        {
            servis.IsNew = false;
            servis.Serviskod = "000:2756"; // Primary key
            servis.ServisTipKod = 1;
            servis.BolgeKod = "30";
            servis.KisaUnvan = "deneme";
            servis.Unvan1 = "deneme";
            servis.Eposta = "testqtest.com";
            servis.Save();
        }
        catch (Exception hata)
        {
            Console.WriteLine(hata.Message);
        }

If there is a record with the given key value there is no error but if there is no record I am receiving the following error

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

Best Regards Koksal

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 05-Dec-2006 15:06:32   

Hello,

is the PK an identity field?

usus avatar
usus
User
Posts: 27
Joined: 07-Sep-2006
# Posted on: 05-Dec-2006 15:10:04   

No, it is not an identiy field, just as varchar(20)

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 05-Dec-2006 15:27:44   

In a first time, if you try a fetch and a save, is your entity is saved? If not, it could be another problem that the update directly. If so, could you check the ID value?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 05-Dec-2006 15:46:40   

Please also enable DQE tracing and see what the query looks like that's being generated (See troubleshooting and debugging).

Also it's best to set IsNew to false right before Save(), because the change checker routine checks if an existing value is equal to the value set. In a new entity, this always succeeds, in an existing entity (IsNew == false) this only succeeds if the new value is different from the current value, otherwise IsChanged isnt' set to true.

Frans Bouma | Lead developer LLBLGen Pro
usus avatar
usus
User
Posts: 27
Joined: 07-Sep-2006
# Posted on: 05-Dec-2006 16:05:37   

I also tried for the other entities und olso make isnew=false just before the save() but again I am reciving the error message

ozgurdeniz
User
Posts: 1
Joined: 26-Dec-2014
# Posted on: 26-Dec-2014 09:29:14   

usus wrote:

I also tried for the other entities und olso make isnew=false just before the save() but again I am reciving the error message

Hi Koksal could you solve your problem? Because i have the same error. Thanks

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 26-Dec-2014 09:49:15   

Please create a new thread for your problem, as per the forum guidelines. We'll close this thread, and will be waiting for the new one.