Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 8 如何在Windows8中将sqlite表和列映射到c#类_Windows 8_Sqlite - Fatal编程技术网

Windows 8 如何在Windows8中将sqlite表和列映射到c#类

Windows 8 如何在Windows8中将sqlite表和列映射到c#类,windows-8,sqlite,Windows 8,Sqlite,我正在用C#为Windows8构建我的第一个应用程序(我是一个十足的noob)。我创建了一些类。当应用程序运行时,它需要从sqlite数据库读取数据。每个表都有一个类,但我不知道如何将每个类属性映射到数据库中相应的列。 我似乎找不到任何信息,我看到的所有东西似乎都自动映射了它们,或者没有提到它们是如何完成的,例如 public class Person { [PrimaryKey, AutoIncrement] public int Id { get; set; } [MaxLength(30

我正在用C#为Windows8构建我的第一个应用程序(我是一个十足的noob)。我创建了一些类。当应用程序运行时,它需要从sqlite数据库读取数据。每个表都有一个类,但我不知道如何将每个类属性映射到数据库中相应的列。 我似乎找不到任何信息,我看到的所有东西似乎都自动映射了它们,或者没有提到它们是如何完成的,例如

public class Person
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }

[MaxLength(30)]
public string Name { get; set; }

[MaxLength(30)]
public string Surname { get; set; }

}
样品

var query = conn.Table<Person>().Where(x => x.Name == "Matteo");
var result = await query.ToListAsync();
foreach (var item in result)
{
    Debug.WriteLine(string.Format("{0}: {1} {2}", item.Id, item.Name, item.Surname));
}
var query=conn.Table(),其中(x=>x.Name==“Matteo”);
var result=wait query.ToListAsync();
foreach(结果中的var项目)
{
WriteLine(string.Format(“{0}:{1}{2}”,item.Id,item.Name,item.姓氏));
}

有没有我遗漏的东西或是某种教程?我以前从未使用过sqlite。

好吧,我觉得自己很傻。。。事实证明,您必须在类上设置表和列属性。 乙二醇


相关:是否在查询表之前创建表?conn.CreateTable();否数据库中已存在这些表
[Table("sometable")]
class Element
{
    [Column(Name = "id")]
    public int Id { get; set; }

    [Column("columnone")]
    public string PropertyOne {get; set;}

    [Column("columntwo")]
    public string PropertyTwo {get; set;}
}