Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert complex models in a sqlite table?

First of all I should apologize if the question doesn't seem a pro one however I have no idea how to deal with it.

I actually have a Person class in which there are another class namely Address and the Address class itself have properties whose types are another class namely Province and City.

public class Province
{
    public string Name { get; set; }
}

public class City
{
    public string Name { get; set; }
}

public class Address
{
    public Province Province { get; set; }
    public City City { get; set; }
    public string Street { get; set; }
    public string PostalCode { get; set; }
}

public class Person
{
    public long Id { get; set; }
    public string Name { get; set; }
    public string Phone { get; set; }
    public Address { get; set; }

}

I should say I used to work with Mongodb and as many of you may know with Mongodb you can insert , update and delete the document itself . But now the company which I'm working for is moving to windows store applications and it appears that it doesn't work with Mongodb so I've decided to use Sqlite instead however, as I said earlier I have really have no idea how to design the tables so that I can read and write my person objects into them.

So I need your help very badly. please put me in the right path. Any help is appreciated. Thanks in advance.

like image 973
user3530012 Avatar asked Nov 01 '22 20:11

user3530012


1 Answers

SQLLite is much similar to the normal SQL database but some cutdown on complex functionalities, you can create a persons table with all the fields (which are the class properties) and insert it into the table, and select the data accordingly whenever necessary

like image 179
Aghosh Avatar answered Nov 12 '22 16:11

Aghosh