Crosslight SQLite Insert

2 replies. Last post: March 7, 2016 8:19 AM by Yudi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

Hello Crosslight Support,

I have a question about the Insert method of SQLite. The belonging documentation says "Inserts the given item and retrieves its auto incremented primary key if it has one.".

I have a model with a property Id of type int. The property has the attributes [PrimaryKey] and [AutoIncrement]. When I insert an object of this type with a synchronous connection the Insert method always returns 1. This is definitely not the primary key. It looks like it returns the number of affected records.

How can I retrieve the primary key of a newly inserted record?

What if I run the insert within a transaction? How can I retrieve the primary key of a newly inserted record in this scenario?

What about InsertAsync? How does it work here?

Thanks for clarifying.

Best regards,

Thomas

All times are GMT -5. The time now is 11:13 PM.
Previous Next