0

Simply i wanna know

update table set (name,surname) values ('John','Locke') where Id=1 sql statment equivalent in llblgen, i tried below code but it didn't work.

            Entity e = new Entity();
            entity.Id = 1;
            entity.name = "John";
            entity.surname = "Locke";
            entity.Save();

can anyone help?

dextererer
  • 65
  • 2
  • 3
  • 8

1 Answers1

2

Basically what you are doing above is creating a totally new entity. To update an existing one use this:

Entity e = new Entity(1);
entity.name = "John";
entity.surname = "Locke";
entity.Save();

The key is the first line. As you are using SelfServicing, in that line LLBLGen Framework will try to fetch the entity, if it exists on DB then the data is retrieved into the entity, otherwise the entity is treated as new. As the entity exists on DB, the values that are actually changed (i.e. the fetched field value is different from the one you actually set) will be used in the UPDATE sql query.

This is explained in the documentation.

David Elizondo
  • 1,123
  • 1
  • 7
  • 16