SQLite net PCL - 简单选择 [英] SQLite net PCL - Simple select

查看:51
本文介绍了SQLite net PCL - 简单选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Windows 应用程序中的 SQLite,现在我正在 Xamarin 中开发一个便携式应用程序,所以我使用插件 sqlite net pcl,但我很难理解它是如何工作的.

I use SQLite from windows app and now I am developing in Xamarin a portable app so I am using the plugin sqlite net pcl and I am having great trouble to understand how it works.

我有一个由 te 创建的表:

I have a table that is created by te following:

public class Config
    {
        public string IP { get; set; }
        [SQLite.Net.Attributes.Default(true, "Client 2")]
        public string ID { get; set; }
    }

并创建表:

db.CreateTable<Model.Config>();

问题:现在我想选择 ID 列中的值,我执行以下操作:

Problem: Now I want to select the value in ID column and I do the following:

List<string> hhid = db.Query<string>("select ID from Config",null);

我收到此异常:未将对象引用设置为对象的实例"

如何进行简单的选择以找到该字段?

How can I make a simple select to find this field?

感谢您的提示

推荐答案

希望这对我身边的人有用...

Hoping this will be usefull to someone in my place...

在方括号 (<>) 之间是表名:

Between the brackets (<>) goes the table name:

db.Query<TableName>("select * from ....");

一些对我有用的例子:

简单选择:

var list = db.Query<MyTableName>("select * from MyTableName");

选择有限制:

var list = db.Query<MyTableName>("select * from MyTableName where lastname=? and firstname=?", lastnameValue, firstNameValue);

这篇关于SQLite net PCL - 简单选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆