Insert List Of Items Into Single Row In Xamarin Forms SQLite DB

Insert List Of Items Into Single Row In Xamarin Forms SQLite DB

Save model contains a list of objects into a single row in the same table using 'SQLiteNetExtensions' NuGet package in xamarin forms.

Most Xamarin.forms developers prefer 'SQLite' for storing data into the local DB. The main limitation of the SQLite DB is it can't insert a model which contains any of the properties having a list data type. Here we can see how to save the model which contains any of the properties having list data type in the same table in a single row.

These are the steps to follow to save the data in the same table in a single row.

'SQLiteNetExtension' or 'SQLiteNetExtension.Async' NuGet package is required to install in project solution.

Add 'TextBlob' attribute to the model containing List data type property. 

public class Person  
{  
  public Person()  
  {  
     Id = Guid.NewGuid().ToString();  
  }  

  [PrimaryKey]  
  public string Id { get; set; }  
  public string Name { get; set; }        
  [TextBlob("AddressesBlobbed")]  
  public List<Address> Addresses { get; set; }  
  // serialized addresses  
  public string AddressesBlobbed { get; set; }   
}  
public class Address  
{  
  public string StreetName { get; set; }  
  public string Number { get; set; }  
  public int PostalCode { get; set; }  
  public string Country { get; set; }  
  public DateTime CurrentDay { get; set; }  
  public double CityNo { get; set; }  
  public bool Values { get; set; }  
}  

xamarin sqlite db xamarin forms

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Xamarin Forms Training Institute | Xamarin Forms Development Classes | Xamarin Training

Xamarin Training course is primarily designed for Beginner(s)/Professional(s) who want to learn how to develop native cross-platform apps with C# that run-on Android, iOS and Windows.

Learn How to Add App Themes for Xamarin.Forms

Learn how to add dark and light themes to your applications using Xamarin.Forms 4.7 and customize color styles in your app UI.

Xamarin.Forms 5 Preview: Advanced UI Controls for Beautiful Apps

Xamarin,Forms 5 Preview is now available. The pre-release brings you more interactive controls with CarouselView, Paths, Gradients, and more.

Xamarin.Forms Shell Quick Tip - Modal Navigation

Control exactly how your pages are displayed when navigating leveraging the PresentationMode built into Xamarin Today, I want to talk about a common feature of navigation where a new page pops up over the current page.

Watch the Xamarin Podcast: Inverter Converter and Xamarin.Forms 4.7 |

James and Matt will talk about multi-bindings and how using it in the right way will unleast the mysterious beast Inverter Converter.