【问题标题】:What's the most simple way to get the value of a single column from a single row table in SQLite using C# sqlite-net-pcl library使用 C# sqlite-net-pcl 库从 SQLite 中的单行表中获取单列值的最简单方法是什么
【发布时间】:2020-06-07 16:59:18
【问题描述】:

在 SQLite 中是否有更好的方法来获取 Schema 表中唯一版本列的值:

db2.CreateTable<Schema>();
db2.Insert(new Schema() { SchemaGuid = new Guid().ToString(), Version = 1 });
public class Schema
{
    [PrimaryKey, NotNull]
    public string SchemaGuid   { get; set; }
    public int    Version      { get; set; }
}

var version = RunQuery<Schema>($"SELECT * FROM Schema").FirstOrDefault().Version;

另外,如果我想更新到 version = 2。如何使用 SQLite 的 sqlite-net-pcl 库来做到这一点?

【问题讨论】:

    标签: c# sqlite xamarin


    【解决方案1】:

    我不确定这是否比你已经在做的更简单

    var version = RunQuery<int>($"SELECT Version FROM Schema").FirstOrDefault();
    

    【讨论】:

      猜你喜欢
      • 2020-09-27
      • 2010-09-15
      • 2015-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-16
      相关资源
      最近更新 更多