动态 LINQ 和 CSLA 业务列表库

发布于 2024-07-15 13:02:39 字数 456 浏览 3 评论 0原文

我遇到了一个简直要了我的命的问题。 我的一个 CSLA 对象(假设是父级)有许多子级(我们称它们为子级 - 子级列表)。 Parent 是可编辑根 (BusinessBase),Children 是可编辑子列表 (BusinessListBase),Child 是可编辑子项。

我想做的是这样做: 父 x = Parent.GetParent(id); IQueryable y = Parent.MyChildren.OrderBy("年龄 DESC");

理论上,y 应该填充按年龄降序排序的子级集合(假设“Age”是 Child 对象的属性)。

但是,我得到的是 y.Count() = 0。虽然如果我执行 Parent.MyChildren.Count() 则没有 0。这是动态 LINQ 或 CSLA 中的错误吗? 对我来说,这个(错误)不会发生在只读列表中。

帮助! 乔

I got a problem that is just killing me. One of my CSLA object (let's say Parent) has many children (let's call them Children - a list of Child). Parent is a Editable Root (BusinessBase) and Children is an Editable Child List (BusinessListBase) and Child is Editable Child.

What I am trying to do is to do this:
Parent x = Parent.GetParent(id);
IQueryable y = Parent.MyChildren.OrderBy("Age DESC");

In theory, y then should be filled with a collection of children sorted descendingly by their age (assuming "Age" is a property of Child object).

But, what I got is that y.Count() = 0. Although if I do a Parent.MyChildren.Count() there aren't 0. Is this a bug in Dynamic LINQ or CSLA? This (the error) does not happen in readonly list for me.

Help!
Joe

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

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

发布评论

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

评论(1

半衬遮猫 2024-07-22 13:02:39

乔,

这是一个可能有帮助的线索。 您对可编辑列表和只读列表之间差异的评论让我很好奇,所以我更深入地研究了。

根据我对 CSLA 3.5 代码的深入了解,BusinessListBase 实现了 IQueryable(实际上它是 CSLA 代码中的“C”,如“Child”中的那样)。 ReadOnlyListBase 类没有。

这可能会影响正在调用哪个动态 LINQ OrderBy 扩展方法(有两个),而 IQueryable 的方法只是调用常规 IQueryable 的 OrderBy 版本。

另一方面,如果您跟踪 BusinessListBase 中的 IQueryable,则 Provider 属性(类型为 IQueryProvider)将委托给 CslaQueryProvider。

public IQueryProvider Provider
{
  get {
    return new Linq.CslaQueryProvider<T, C>(this);
  }
}

综上所述,由于我必须花费的时间有限,我认为进一步深入研究(使用调试器,呃!) CSLA LINQ 内容可能是有必要的。 从其他地方的其他讨论和后续行动中,我看到您还指出了为 CSLA 记录的错误/问题。 链接如下:

CSLA 问题 ID 326 - OrderBy 应返回与绑定网格配合使用的 LinqBindingList

我怀疑它与 BusinessListBase 的 IQueryable 实现有关。 再说一次,它看起来不像 ReadOnlyListBase 直接或通过继承(在我的 CSLA 3.5 副本中)实现 IQueryable。

希望有帮助。

杰夫·米勒

Joe,

Here's a clue that might help. Your comment about the difference between an editable list and a readonly list got me curious, so I dug a little deeper.

Based on what I could tell from digging into the CSLA 3.5 code, BusinessListBase implements IQueryable (actually it's "C" in the CSLA code, as in "Child"). The ReadOnlyListBase class does not.

This may affect which Dynamic LINQ OrderBy extension method is being called (there are two), and the one for IQueryable simply calls the version of OrderBy for the regular IQueryable.

On the other hand, if you follow the trail of IQueryable in BusinessListBase, the Provider property (of type IQueryProvider) delegates to the CslaQueryProvider.

public IQueryProvider Provider
{
  get {
    return new Linq.CslaQueryProvider<T, C>(this);
  }
}

All of that to say, with the limited time I had to spend, I think delving further (with a debugger, duh!) into the CSLA LINQ stuff is probably warranted. From other discussion and follow-up elsewhere, I saw you also pointed to a bug/issue recorded for CSLA. Here's the link:

CSLA Issue ID 326 - OrderBy should return a LinqBindingList that works with Bound Grids

My suspicion is that it has more to do with BusinessListBase's implementation of IQueryable than anything else. And again, it doesn't look like ReadOnlyListBase implement IQueryable, either directly or via inheritance (in my copy of CSLA 3.5).

Hope that helps.

Jeff Miller

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