Subsonic 3 LINQ 投影问题是否已修复?

发布于 2024-09-07 01:53:43 字数 2876 浏览 1 评论 0原文

我目前遇到了此处(以及其他几个地方)提到的问题:Subsonic 3 Linq Projection Issue< /a>

这是使用 3.0.0.4 发行包时发生的情况,当我从 GitHub 获取最新版本并构建它时也会发生这种情况。

我正在使用 LINQ 模板。

我有这样的代码:

        var newModel = new ViewModels.HomeIndexViewModel() {
            PulseListViewModel = 
                new ViewModels.PulseListViewModel 
                {
                    Pulses = from p in _pulseQuery
                             join a in _accountQuery on p.AccountId equals a.AccountId
                             orderby p.CreateDate descending
                             select new PulseListViewModel.Pulse() 
                                {
                                      AccountName = a.Name
                                    , Category = p.Category
                                    , CreateDate = p.CreateDate
                                    , Link = p.Link
                                    , Message = p.Message
                                    , Source = p.Source
                                    , Title = p.Title
                                }
                }
        };

但 AccountName 始终为空。

如果我将 AccountName 更改为 Name:

        var newModel = new ViewModels.HomeIndexViewModel() {
            PulseListViewModel = 
                new ViewModels.PulseListViewModel 
                {
                    Pulses = from p in _pulseQuery
                             join a in _accountQuery on p.AccountId equals a.AccountId
                             orderby p.CreateDate descending
                             select new PulseListViewModel.Pulse() 
                                {
                                    Name = a.Name
                                    , Category = p.Category
                                    , CreateDate = p.CreateDate
                                    , Link = p.Link
                                    , Message = p.Message
                                    , Source = p.Source
                                    , Title = p.Title
                                }
                }
        };

它工作正常。但这在我们的项目中是不可接受的;我不能总是让名字排列起来(此外,如果可以的话,这会让事情变得不那么清楚)。

但我很困惑,因为这个问题似乎已经得到解决:

“修复了投影返回空或空设置的问题”

-- http://blog.wekeroad.com/2010/03/21/subsonic-3-0-0-4-released

那么,谁能告诉我:这个问题没有解决吗?我是否必须应用在 http://github.com/funky81/SubSonic-3.0/commit/aa7a9c1b564b2667db7fbd41e09ab72f5d58dcdb 来完成这项工作吗?或者我错过了什么。因为查看当前的 SubSonic 源代码,似乎已包含此修复程序。我觉得这应该是简单且有效的,但我却在这上面花费了过多的时间。

I'm currently experiencing the issue mentioned here (and several other places): Subsonic 3 Linq Projection Issue

This is occurring using the 3.0.0.4 release package, and it also occurs when I grab the latest from GitHub and build it.

I am using the LINQ Templates.

I have this code:

        var newModel = new ViewModels.HomeIndexViewModel() {
            PulseListViewModel = 
                new ViewModels.PulseListViewModel 
                {
                    Pulses = from p in _pulseQuery
                             join a in _accountQuery on p.AccountId equals a.AccountId
                             orderby p.CreateDate descending
                             select new PulseListViewModel.Pulse() 
                                {
                                      AccountName = a.Name
                                    , Category = p.Category
                                    , CreateDate = p.CreateDate
                                    , Link = p.Link
                                    , Message = p.Message
                                    , Source = p.Source
                                    , Title = p.Title
                                }
                }
        };

But AccountName is always null.

If I change the AccountName to Name:

        var newModel = new ViewModels.HomeIndexViewModel() {
            PulseListViewModel = 
                new ViewModels.PulseListViewModel 
                {
                    Pulses = from p in _pulseQuery
                             join a in _accountQuery on p.AccountId equals a.AccountId
                             orderby p.CreateDate descending
                             select new PulseListViewModel.Pulse() 
                                {
                                    Name = a.Name
                                    , Category = p.Category
                                    , CreateDate = p.CreateDate
                                    , Link = p.Link
                                    , Message = p.Message
                                    , Source = p.Source
                                    , Title = p.Title
                                }
                }
        };

It works fine. But that's not acceptable in our project; I can't always make the names line up (besides the fact that it would make things less clear if I could).

But I'm quite confused because it would seem this issue's been fixed:

"Fixed issue where Projections were returning null or empty settings"

-- http://blog.wekeroad.com/2010/03/21/subsonic-3-0-0-4-released

So, can anyone tell me: Is this issue not fixed, and do I have to apply the changes found here at http://github.com/funky81/SubSonic-3.0/commit/aa7a9c1b564b2667db7fbd41e09ab72f5d58dcdb to make this work? Or am I missing something. Because looking through the current SubSonic source it appears this fix has been included. I feel like this should be simple and work, but instead I've spent an inordinate amount of time on it.

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

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

发布评论

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

评论(3

夜夜流光相皎洁 2024-09-14 01:53:44

如果你(我)根据这里的答案修改SubSonic.Core: Subsonic 3.0 和linq

然后投影就可以正常工作了。

然而,我认为这是一个非常糟糕的解决方案,因为它需要分叉一个项目并导致性能下降一个数量级。

If you (me) modify SubSonic.Core according to the answer here: Subsonic 3.0 and linq

Then the projection works correctly.

However, I consider this a very bad solution as it requires forking a project and introducing an order of magnitude performance decrease.

梦萦几度 2024-09-14 01:53:44

您能否向我发送更多代码(尤其是 _pulseQuery 和 _accountQuery 后面的代码),以便我可以解决此问题。您是否使用 SimpleRepository 或 ActiveRecord 方法或直接使用 Query 对象?

Could you send me a little bit more code (especially what's behind _pulseQuery and _accountQuery) so I can fix this issue. Are you using SimpleRepository or the ActiveRecord approach or Query objects directly?

柠檬色的秋千 2024-09-14 01:53:44

在这里恢复一个旧主题,但以防万一有人稍后搜索这个...

我也“修复”了同样的问题,并在评论中添加了一些解释,在我的 GitHub 上的分支中的此提交中: https://github.com/rally25rs/SubSonic-3.0/commit/61af6aeb2ebb95f486d8df533bf13c8754d 443e2

其实还有一个稍微深一点的问题这里也有。如果您选择使用“标准 .NET 内置”投影,则某些 SubSonic 单元测试开始失败,因为 SS 在其投影生成中执行了一些 .NET 投影不会执行的额外操作,因此某些SS 的预期功能不起作用。

就我个人而言,我认为,较慢的性能(尽管我没有注意到速度下降)是为正确数据付出的很小的代价。

Reviving an old topic here, but in case someone searches for this later...

I also "fixed" this same issue, and put some explanation in the comments, in my fork on GitHub in this commit: https://github.com/rally25rs/SubSonic-3.0/commit/61af6aeb2ebb95f486d8df533bf13c8754d443e2

There is actually a slightly deeper issue here too. If you choose to use the "standard .NET built-in" projections, then some of the SubSonic unit tests start to fail, because SS does some extra stuff in its projection generation that the .NET projection doesn't do, so some of the expected functionality of SS doesn't work.

Personally, I think that, and the slower performance (though I haven't noticed a speed decrease) is a small price to pay for correct data.

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