How to insert complex models in a sqlite table?

我与影子孤独终老i 提交于 2019-12-10 18:36:24

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/24624768/how-to-insert-complex-models-in-a-sqlite-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!