gpt4 book ai didi

c# - 如何使用C#将自定义对象保存到Windows Phone8上的sqlite数据库中?

转载 作者:行者123 更新时间:2023-12-03 19:42:58 25 4
gpt4 key购买 nike

如何使用C#将自定义对象保存到Windows Phone8上的sqlite数据库中?

public class Person
{

public int Id { get; set; }


public string Name { get; set; }


public string Surname { get; set; }

public List<Address> Items { get; set; }

public List<SubAddress> Subaddress { get; set; }

}
public class Address
{
public string city { get; set; }
public string state { get; set; }
public string pin { get; set; }
public List<SubAddress> Subaddress { get; set; }
}
public class SubAddress
{
public string SubAddresscity { get; set; }
public string SubAddressstate { get; set; }
public string SubAddresspin { get; set; }
}




Person person = new Person
{
Name = "Matteo",
Surname = "Pagani",
Items = new List<Address>
{
new Address
{
city="fdsdf",state="sfds",pin="dsfsd",Subaddress=new List<SubAddress>
{
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
},
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
},
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
}
},

},
new Address
{
city="fdsdf",state="sfds",pin="dsfsd",Subaddress=new List<SubAddress>
{
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
},
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
}
}
},
new Address
{
city="fdsdf",state="sfds",pin="dsfsd",Subaddress=new List<SubAddress>
{
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
}
}
},
new Address
{
city="fdsdf",state="sfds",pin="dsfsd",Subaddress=new List<SubAddress>
{
}
}
},
Subaddress = new List<SubAddress>
{
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
},
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
},
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
},
new SubAddress
{
SubAddresscity="llll",
SubAddressstate="ffff",
SubAddresspin="gggg"
}
}

};


如何将人对象直接保存到数据库中以及如何检索对象?

是否可能,你能帮我实现吗。

谢谢 ......

最佳答案

您的问题很广泛。首先,您应该学习-how to store objects in tables。然后,如何store complex objects in tables等。用几行文字回答是不可能的。甚至需要对SQL数据库有一般的了解。

关于c# - 如何使用C#将自定义对象保存到Windows Phone8上的sqlite数据库中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26736584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com