Open GilbertoBitt opened 7 years ago
I had the same problem, too. When actually looking at the source code and confirming it, in order to be able to set the composite Primary Key, since I had to edit the source code largely, instead of setting a compound unique index and substituting it with a composite primary key We handled it in the same way as we treated it. (If I have time, I'd like to fix it so that I can set composite Primary Key later...)
@TakuKobayashi my work around was a little more simple! i create the custom command for insert or replace using insert or ignore than update in the command. look here the code;
public void UpdateOrReplateInventory(DBOINVENTARIO _itemUpdate){
//Connection.Query("UPDATE Book SET Name = '" + inputfield.text + "' WHERE Id = " + intBookNo);
object[] argss = new object[12];
argss[0] = _itemUpdate.idItem;
argss[1] = _itemUpdate.idUsuario;
argss[2] = _itemUpdate.quantidade;
argss[3] = _itemUpdate.dataUpdate;
argss[4] = _itemUpdate.dataInsert;
argss[5] = _itemUpdate.ativo;
argss[6] = _itemUpdate.quantidade;
argss[7] = _itemUpdate.dataUpdate;
argss[8] = _itemUpdate.dataInsert;
argss[9] = _itemUpdate.ativo;
argss[10] = _itemUpdate.idItem;
argss[11] = _itemUpdate.idUsuario;
//object[] argss02 = new object[6];
String command01 = "INSERT OR IGNORE INTO DBOINVENTARIO (idItem, idUsuario, quantidade, dataUpdate, dataInsert, ativo) VALUES(?,?,?,?,?,?); ";
String command02 = "UPDATE DBOINVENTARIO SET quantidade=?,dataUpdate=?,dataInsert=?,ativo=? WHERE idItem=? AND idUsuario=?;";
String commandFull = command01 + command02;
// _connection.Query(commansd, argss);
//_connection.CreateCommand(commansd,argss);
_connection.Execute(commandFull,argss);
//_connection.Execute(command02,argss);
}
Well, is it not OK to use "INSERT OR REPLACE INTO ..." command?
@TakuKobayashi it's ok but the correct should be using LINQ to fast interaction with tables contain 2 primary keys because in my case using command i need write all the command code to every table on my database that has constraint key.
I want to use more than 1 primary key in my case only 2! and i can't seen to get it working or it doesn't support. help me...