views:

88

answers:

2

I'm currently experiencing the issue mentioned here (and several other places): http://stackoverflow.com/questions/1105052/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.

+2  A: 

If you (me) modify SubSonic.Core according to the answer here: http://stackoverflow.com/questions/1655354/subsonic-3-0-and-linq/1670198#1670198

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.

qstarin
+2  A: 

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?

Saintedlama
qstarin
Saintedlama, I too suffer from this problem using 3.0.0.4 but I have been unable to reproduce it in a smaller set -- outside of a larger project. I have however illustrated two other commonly posted issues in a small sample set at http://github.com/andymeadows/SubSonic-Defect-Help
andymeadows