【问题标题】:Using the return type IQueryable<TABLE_1>使用返回类型 IQueryable<TABLE_1>
【发布时间】:2011-07-03 07:39:33
【问题描述】:

我是 silverlight 的新手,很多帖子都表明使用 observablecollection 是最好的。

Domainservice1 返回 IQUERYABLE 类型。

如何使用这个返回类型 银光面?

如何转换/转换返回的数据 到可观察的集合?

DomainServices1.cs

public IQueryable<TABLE_1> GetTABLE_1()
        {

            return this.ObjectContext.TABLE_1;
        }

*HOME.XAML.CS***

public Home()
        {
            InitializeComponent();

            this.Title = ApplicationStrings.HomePageTitle;


            Web.DomainService1 dservice = new Web.DomainService1();

            EntityQuery<Web.TABLE_1> query=new EntityQuery<Web.TABLE_1>();

            query = dservice.GetTABLE_1Query();

            //Convert result to ObservableCollection

            //bind the grid ITEM SOURCE

        }

【问题讨论】:

    标签: silverlight-4.0 ienumerable observablecollection iqueryable


    【解决方案1】:

    在您枚举集合之前,IQueryable 不会返回结果。因此,例如,如果您想使用 .where() 限制 dservice.getTable_1Query 的结果,您可以...

    要将对象放入可观察的集合中,您可以像这样列出查询

    observablecollection<Table1> t=new observablecollection<Table1>(query.ToList());
    

    我实际上认为你还需要做一些事情(加载操作就是我的工作方式) 我处于 linq 动态的学习阶段,但是从其他应用程序中我不得不将返回的结果转换为可观察的集合;我就是这样做的。我实际上写了一个扩展,以便我可以 .ToObservableCollection

    【讨论】:

      猜你喜欢
      • 2020-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-23
      • 2011-10-04
      • 1970-01-01
      相关资源
      最近更新 更多