C# C/XAML从包含字符串的Linq查询分配选择器列表项资源属性错误:CS0029

C# C/XAML从包含字符串的Linq查询分配选择器列表项资源属性错误:CS0029,c#,xaml,xamarin,casting,anonymous-types,C#,Xaml,Xamarin,Casting,Anonymous Types,我试图使用Linq查询本地SQLite数据库来分配选择器ItemsSource属性。然而,我得到的是{Page_Title=test1},而不是test1。 其中: Page_Title是SQLite表中的列名 测试1是我想要返回的值 我假设我得到的原因是因为我使用的是列表而不是字符串。但是,当我尝试使用列表时,会出现以下错误: CS0029:无法将类型System.Collections.Generic.List隐式转换为System.Collections.Generic.List字符串 我

我试图使用Linq查询本地SQLite数据库来分配选择器ItemsSource属性。然而,我得到的是{Page_Title=test1},而不是test1。 其中:

Page_Title是SQLite表中的列名

测试1是我想要返回的值

我假设我得到的原因是因为我使用的是列表而不是字符串。但是,当我尝试使用列表时,会出现以下错误:

CS0029:无法将类型System.Collections.Generic.List隐式转换为System.Collections.Generic.List字符串

我尝试了一个.ConvertAll来转换字符串,它确实删除了{Page_Title=}以仅返回测试1,但它作为列表中的一个项目作为每个字符返回。例如:

T

e

t

一,

带对象的代码

        VM_AnalyzePage CurrentPage = new VM_AnalyzePage();
                var pageList = (from UserPageTbl in conn.Table<UserPageTbl>()
                            where UserPageTbl.User_ID == App.user
                            select new
                            {
                                UserPageTbl.Page_Title

                            }).Distinct().OrderBy(Page_Title => Page_Title).ToList<object>();


            CurrentPage.PageList = pageList;
用字符串编码

            var pageList = (from UserPageTbl in conn.Table<UserPageTbl>()
                            where UserPageTbl.User_ID == App.user
                            select new
                            {
                                UserPageTbl.Page_Title

                            }).Distinct().OrderBy(Page_Title => Page_Title).ToList();


            CurrentPage.PageList = pageList;
这是我试图设置其值的类。请注意,当我尝试转换为字符串时,我会在下面将对象更改为字符串:

public class VM_AnalyzePage : INotifyPropertyChanged

{

    //properties
    private List<object> pageList;


    public List<object> PageList
    {
        get
        {
            return pageList;
        }
           
        set
        {
            pageList = value;
        }
    }
我还尝试将pageList变量强制转换为下面的列表字符串,但随后出现了相同的错误:

            List<string> pageList = (from UserPageTbl in conn.Table<UserPageTbl>()
                            where UserPageTbl.User_ID == App.user
                            select new
                            {
                                UserPageTbl.Page_Title

                            }).Distinct().OrderBy(Page_Title => Page_Title).ToList();


            CurrentPage.PageList = pageList;

我能够通过用真正的LINQ语句替换SQL语句来克服:

                List<string> pageList = conn.Table<UserPageTbl>().Where(t => t.User_ID == App.user).Select(t=>t.Page_Title).Distinct().ToList();