var innerEx = from b in Query.All<RegBalance>()
                          join p in Query.All<RegCalculatedPrice>() on new { b.FinTool, b.AuthDate } equals
                              new { p.FinTool, AuthDate = (DateTime?)p.ActualizationDate }
                          where b.ActualVolume > 0
                          select
                              new AnonymousClass
                                  {
                                      FinTool = b.FinTool,
                                      AuthDate = b.AuthDate,
                                      Fund = b.Fund,
                                      ActualVolume = (decimal?)b.ActualVolume,
                                      VolumeDelta = (decimal?)b.VolumeDelta,
                                      Price = (decimal?)null
                                  };
            var balEx = from b in Query.All<RegBalance>()
                        select
                            new AnonymousClass
                                {
                                    FinTool = b.FinTool,
                                    AuthDate = b.AuthDate,
                                    Fund = b.Fund,
                                    ActualVolume = (decimal?)b.ActualVolume,
                                    VolumeDelta = (decimal?)b.VolumeDelta,
                                    Price = (decimal?)null
                                };

            var unionPrice = from p in Query.All<RegCalculatedPrice>()
                             select
                                 new AnonymousClass
                                     {
                                         FinTool = p.FinTool,
                                         AuthDate = (DateTime?)p.ActualizationDate,
                                         Fund = (Fund)null,
                                         ActualVolume = (decimal?)null,
                                         VolumeDelta = (decimal?)null,
                                         Price = (decimal?)p.Price
                                     };

            var unionRes = balEx.Except(innerEx).Union(unionPrice)
                .OrderBy(a => a.FinTool).ThenBy(a => a.AuthDate).ThenBy(a => a.Fund);

I've got translation exception, it cannot union those results, why??


Updated at 09.08.2010 8:26:19

hm... why? Peoply usually union different table results

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked Aug 05 '10 at 07:57

xumix's gravatar image

xumix
425757682

edited Aug 12 '10 at 09:39

You can, but item types there (i.e. value of type parameter T in IQueryable<t>) must be identical.

(Aug 05 '10 at 07:57) Alex Yakunin Alex%20Yakunin's gravatar image

Some new comment goes here for testing purposes. There are some edits happens.

(Aug 16 '10 at 09:44) Sergey Sergey's gravatar image

2 Answers:

This issue has been resolved.

answered Aug 17 '10 at 00:08

Alexis%20Kochetov's gravatar image

Alexis Kochetov
1414

AFAIK, it's possible to union only result sets of similar structure: http://msdn.microsoft.com/en-us/library/ms180026.aspx - in our case this means there must be identical types.

Ups, sorry - I just noticed you use the same DTO type, so this should work. I'll ask our guys to check if this is complex to fix this.

answered Aug 09 '10 at 09:42

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Fixed, update will be available soon.

(Aug 09 '10 at 09:42) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA