简体   繁体   English

如何使用 SQLite 从数据库表中仅获取一个字段?

[英]How can I get just one field from a database table with SQLite?

I have this class:我有这个 class:

public class CarConfiguration : ObservableObject
{
    [PrimaryKey, NotNull]
    public long CarConfigurationId { get; set; }
    public string Name { get; set; }
}

With this code I know I can get all the rows:使用此代码,我知道我可以获得所有行:

public List<CarConfiguration> GetUniqueCarConfigurationNames()
{
   return db2.Table<CarConfiguration>().ToList();
}

But how can I get all the unique names only sorted by name?但是我怎样才能得到所有唯一按名称排序的名称呢?

use a Query使用查询

return db2.Query<string>("select distinct Name from CarConfiguration order by Name").ToList();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从表格中仅获得一列? - How can I get just one column from a table? 如何使用SQLite.NET从现有的sqlite数据库中获取表名列表? - How can I get a list of table names from an existing sqlite database using SQLite.NET? 如何获取数据库表的字段名称? - How can I get the field names of a database table? 如何从SQLite表中获取实际的日期时间值? - How can I get the actual datetime values from a SQLite table? 如何在 MongoDB C# 中只读取一个字段? - How can I read just one field in MongoDB C#? 如何从Sqlite请求中获取一个字段值? - How to get one field value from Sqlite request? 从数据库获取一个单元格的值到一个字符串中:我不能仅从下一行就从当前行中获取它 - Getting a value of a cell from database into a string: I can't get it from the current row just from the next one 如何获取 SQLite 数据库中表的索引列 - How do I get the indexed columns of a table in SQLite database 如何使用SQlite在数据库表中设置收集对象? - How can I set the collection object in database table using SQlite? 如何从 SQLite 数据库中以字符串数据类型的形式从 Select 查询中获取数据? - How can I get data from a Select query as a String data type from a SQLite database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM