我正在使用 Simple.Data 并想知道是否可以选择单个列,然后将其转换为字符串值列表。例如使用下面的查询我得到错误:
无法将类型“Simple.Data.SimpleRecord”隐式转换为“字符串”
var result = _database.ParentRegionList.All()
.Select(_database.ParentRegionList.RegionName)
.Where(_database.ParentRegionList.RegionName.Like(startsWith + "%"))
.Distinct()
.ToList<string>();
但是,如果我创建一个具有字符串类型的单个公共属性“RegionName”的 LocationAutoComplete 类,则转换工作正常。
var result = _database.ParentRegionList.All()
.Select(_database.ParentRegionList.RegionName)
.Where(_database.ParentRegionList.RegionName.Like(startsWith + "%"))
.Distinct()
.ToList<LocationAutoComplete>();