Hello. The application has the following two tables, which are filled with data: enter image description here

The "Store" field in the application is populated via the Picker drop-down list. To do this, use the class PurchasePage. It defines the index of the current element in the drop-down list by searching for an element in the array by name:

public PurchasePage() { InitializeComponent(); //Заполняем выпадающий список var StoreArray = App.database.GetStores().ToArray(); var a = new List<string>(); foreach (var StoreName in StoreArray) { Picker.Items.Add(StoreName.store_name); } //Определяем текущий элемент в выпадающем списке var PurchaseArray = App.database.GetPurchases().ToArray(); foreach (var Purchase in PurchaseArray) { //GetStore производит выборку по id var Store = App.database.GetStore(Purchase.store_id); var curArr = Picker.Items.IndexOf(Store.store_name); if(curArr != -1) Picker.SelectedIndex = curArr; } } 

Next, to save the data, the name of the currently selected item is determined:

 var selectedStore = Picker.Items[Picker.SelectedIndex]; 

The variable selectedStore is passed to the SavePurchase method, which saves data to a table. In this method, the identifier is selected by name:

  public int SavePurchase(Purchase item, string store) { var store_id = database.Query<Store>("Select store_id from Store where store_name=\""+ store + "\""); item.store_id = store_id[0].store_id; if (item.purchase_id != 0) { database.Update(item); return item.purchase_id; } else { return database.Insert(item); } } 

How to pass the value of the identifier immediately to the drop-down list so that each time you do not have to search for its value by the name of the element?

    0