SQLite的净PCL - 简单的SELECT [英] SQLite net PCL - Simple select

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

问题描述

我使用SQLite从Windows应用程序,现在我在Xamarin的便携式应用程序,所以我使用的插件源码网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?

感谢您的任何提示

推荐答案

希望,这将是有用的人在我的地方...

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

括号之间(小于>)变为表名:

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

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



的一些例子为我工作:



简单的选择:



Some examples that worked for me:

Simple select:

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



选择有限制的:



Select with restrictions:

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

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

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