Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subsonic 3 LINQ Projection issue, fixed or no?

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.

like image 653
quentin-starin Avatar asked Jun 24 '10 15:06

quentin-starin


1 Answers

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.

like image 199
quentin-starin Avatar answered Sep 23 '22 06:09

quentin-starin