sqlite 如何在Xamarin表单SQL Lite中选择动态列

ep6jt1vc  于 2023-01-09  发布在  SQLite
关注(0)|答案(1)|浏览(154)

我使用Xamarin表单。我想使用SQL Lite查询选择我的动态列,但我得到了一个错误。
下面是我的模型:

public class MyWords
{

[PrimaryKey, AutoIncrement]
public int ID { get; set; }

[JsonProperty(PropertyName = "id")]
public Guid MyId { get; set; } = Guid.NewGuid();

[JsonProperty(PropertyName = "languagevalue1")]
public string LanguageValue1 { get; set; }

[JsonProperty(PropertyName = "languagevalue2")]
public string LanguageValue2 { get; set; }

[JsonProperty(PropertyName = "languagevaluecombine")]
public string LanguageValueCombine { get { return LanguageValue1 + "  " + Separator + "  " + LanguageValue2; } }

}

我想获取列“languagevaluecombine”的值,但出现错误。
下面是我如何查询我的列“languagevaluecombine”表:

var ListCombine = conn.QueryAsync<MyWords>("select DISTINCT languagevaluecombine from MyWords ");

下面是得到的错误:

SQLite.SQLiteException has been thrown
no such column: languagevaluecombine

但是当我尝试使用列“languagevalue2”时,我认为它不是一个动态列
谢谢你的帮忙

ggazkfy8

ggazkfy81#

首先,将数据加载到C#类中

var data = conn.Table<MyWords>().ToList();

则可以提取计算属性

var words = data.Select(x => x.LanguageValueCombine).ToList();

相关问题