我想使用sqlite数据库返回一些值,代码如下:
public Dictionary<string, string> GetRegistry()
{
var table = this.connection.Table<Registry>();
Dictionary<string, string> RegistryItems = new Dictionary<string, string>();
foreach (var item in table)
{
}
}
鉴于var item
代表一个sql表项,所以说item.Age
将是一个年龄,依此类推。我希望能够返回一个字典,我可以这样做:
Dictionary registry = this.GetRegistry();
int myAge = registry["Age"];
我应该在foreach
条款中做些什么来实现这一目标?
提前谢谢!
答案 0 :(得分:0)
鉴于该表意味着sql表,您可以执行以下操作:
public Dictionary<string, string> GetRegistry()
{
var table = this.connection.Table<Registry>();
Dictionary<string, string> RegistryItems = new Dictionary<string, string>();
var ages = table.Select(X => x.Name == "Age").ToList();
}