Open jacksonh opened 11 years ago
My proposal for implementing this is to add a new attribute AutoIncrementIfNotNull that can only be added to properties of Object or Nullable type. Columns with this attribute will still be included in the insert columns list, and if they are null they will get autoincremented. If the columns have a non-null value, that value will be inserted.
sqlite does most of this for us, all we need to do is make sure these columns are in the list of mapped columns.
Wow. Can't believe this issue is still open. I followed @jacksonh suggestion to deal with the open issue.
its a little bit old issue, but hit it today implementing some migrations. started to code manual sql commands, but ends up with simple two pass code first - create dbrow with only required fields with correct rowid, and then just update them
foreach (var recipe in oldRecipes)
{
dbConnection.Execute($"insert into Recipes (ID) Values ({recipe.ID})");
}
dbConnection.UpdateAll(oldRecipes, false);
may be it helps somebody
According to sqlite docs:
sqlite-net ignores autoincrement primarykey columns when inserting, so its difficult to replicate this behavior.