Tamil Rk

Tamil Rk

  • NA
  • 442
  • 15.8k

How to store large data list in sql lite with quik method

Jul 15 2021 7:40 AM

Hello team,

using Xamarin forms XAML with C# code

I need the best method to store the data in SQL lite. Please find the below table structure.

Table:

public class tblItemList
{
    [Collation("NOCASE")]
    public string parent { get; set; }
    [Collation("NOCASE")]
    public string child { get; set; }
}

I need to store above 1 lack records, and I have a record list in the table class. Currently, I have for loop storing the table data. It is taking more time to save.

code:

List<tblItemList> itemlist = JsonConvert.DeserializeObject<List<tblItemList>>(DecryptString(result));

foreach (tblItemList item in itemlist)
{
    var ddd = await App.Database.SaveItemAsync(item);
}

Table creating method:

public DBworker(string dbPath)
{
    database = new SQLiteAsyncConnection(dbPath);
    database.CreateTableAsync<tblItemList>().Wait();
}

Inserting method:

public Task<int> SaveItemAsync(tblItemList itemList)
{
    // Save a new note.
    return database.InsertAsync(itemList);
}

In saving above 1 lack records, it will take 30 min’s, so I need to store in quick method, please suggest any best method for storing data in SQL lite db.


Answers (1)