Silverlight DomainService 未从 include() 返回信息

发布于 2024-10-21 14:30:56 字数 1466 浏览 6 评论 0原文

我的 RIA DomainService 中有两个查询。一种是使用 linq 的简单 get,另一种是使用 peramiter 和 linq join 的 get。使用 include() 时的简单获取将我想要的数据返回到我的 silverlight 数据网格。带有 join 的则没有,为什么?

这是我的两种方法。最上面的那个是有效的。

    public IQueryable<UserProfile> GetUserProfiles()
    {
        // GetUserProfiles order by sum of carma
        return from up in ObjectContext.UserProfiles.Include("PriceRange")
               where up.Active
               orderby up.SumKarma descending 
               select up;
    }

    public IQueryable<UserProfile> GetUserProfilesByCountyID(int searchCountyID)
    {
        return from up in ObjectContext.UserProfiles.Include("PriceRange")
               join upsc in ObjectContext.UserProfileSearchCounties on up.IDUserProfile equals upsc.IDUserProfile
               where up.Active && upsc.IDSearchCounty == searchCountyID
               orderby up.SumKarma descending
               select up;

    }

更新:根据 Cubicle.Jockey 的评论,我能够解决这个问题。下面是我最终使用的。

    public IEnumerable<UserProfileSearchCounty> GetUserProfilesByCountyID(int searchCountyID)
    {
        return (from upsc in ObjectContext.UserProfileSearchCounties.Include("UserProfile").Include("UserProfile.PriceRange")
                where upsc.UserProfile.Active && upsc.IDSearchCounty == searchCountyID
                orderby upsc.UserProfile.SumKarma descending
                select upsc).ToList();
    }  

I have two queries in my RIA DomainService. one is a simple get using linq and the other is a get with a peramiter and a linq join. the simple get when using include() returns the data i want to my silverlight datagrid. the one with the join does not, why?

here are my two methods. the top one is the one that works.

    public IQueryable<UserProfile> GetUserProfiles()
    {
        // GetUserProfiles order by sum of carma
        return from up in ObjectContext.UserProfiles.Include("PriceRange")
               where up.Active
               orderby up.SumKarma descending 
               select up;
    }

    public IQueryable<UserProfile> GetUserProfilesByCountyID(int searchCountyID)
    {
        return from up in ObjectContext.UserProfiles.Include("PriceRange")
               join upsc in ObjectContext.UserProfileSearchCounties on up.IDUserProfile equals upsc.IDUserProfile
               where up.Active && upsc.IDSearchCounty == searchCountyID
               orderby up.SumKarma descending
               select up;

    }

UPDATE: with comment from Cubicle.Jockey i was able to work through this. below is what i ended up using.

    public IEnumerable<UserProfileSearchCounty> GetUserProfilesByCountyID(int searchCountyID)
    {
        return (from upsc in ObjectContext.UserProfileSearchCounties.Include("UserProfile").Include("UserProfile.PriceRange")
                where upsc.UserProfile.Active && upsc.IDSearchCounty == searchCountyID
                orderby upsc.UserProfile.SumKarma descending
                select upsc).ToList();
    }  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空名 2024-10-28 14:30:56

不会返回所有数据,因为您正在执行选择,这只是 UserProfile 而不是您正在执行的联接查询。

All the data is not being returned because you are doing a select on up which is just UserProfile and not the joined query you were performing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文