Support for union

Sep 15, 2009 at 2:19 PM

I've seen that there is no support for union. Is this something that is planned, or does it require a significant code change?




Sep 16, 2009 at 3:54 PM
Edited Sep 16, 2009 at 3:59 PM

I expect union to be very difficult, so I'm loathe to jump in. :-)  The trouble with Union is that LINQ queries can contain hierarchical data while SQL can only have relations with scalar fields, so for many queries there is no good translation that encodes the correct semantics. 

Sep 16, 2009 at 4:17 PM

Ok - I understand what you mean. I've had a look and reasonably quickly decided to ask if you were planning on adding it in rather than trying to add it myself :-)


Mar 15, 2010 at 7:34 PM

If you do decide to implement Union then the number of appreciative people would now increase to 2 :)

Oct 20, 2011 at 11:10 PM

I just started exploring the possibility of adding UNION ALL support for increasing the performance of batch INSERT operations. The current batch RPC method seems okay, but we have a method that blasts data in chunks using UNION ALL (contains many, many new records) rather than many statements..

I've also been studying the current code and think I need to insert a new translator either in the BuildExecuteBatch(...) method that will blow away the "expression" on ColumnAssignments (ultimately, the column values will come in the form of block UNION ALL / SELECT's) and build a set of UnionOperator expressions combined with SELECTs.. Another option I thought of was to rip apart the InsertExpression to recognize that it has column declarations and assignments as two different things. The problem here is that the insert expression processing doesn't seem to know anything about the fact that it's inside of a batch expression... hence my first approach.

This is really leading up to moving to table-valued-parameters for an even better perf boost.

Is anyone already doing this, and does anyone have any hints on where this layer of translation be inserted?