locked
Product Suggestion: Add support for Left, Right, and Full Outer Join to LINQ

    General discussion

  • Description:

     

    VB LINQ has support for Join and Group Join, but to do a Left Join, Right Join, or Full Outer Join, we need to create elaborate, inefficient, convoluted code (see example below)

     

    This has been brought up on the VB Insiders alias, as well as in response to my series of blog posts about Converting SQL to LINQ.  I think this is a common scenario and will be a serious headache for VB customers.

     

    - whorst

     

    Repro Steps:

     

    1. Open a new VB Console Application

    2. Add the below "data" code

     

    Class Customer

        Public CustomerID As Integer?

        Public ContactName As String

        Public Phone As String

        Public Address As String

        Public City As String

        Public State As String

        Public Zip As String

    End Class

     

    Class Order

        Public OrderID As Integer?

        Public CustomerID As Integer?

        Public Cost As Single?

        Public Phone As String

        Public OrderDate As DateTime?

        Public ShippingZip As String

        Public ItemName As String

    End Class

     

    Dim CustomerTable As Customer() = { _

        New Customer With {.ContactName = "Bill Horst", .CustomerID = 112}, _

        New Customer With {.ContactName = "John Doe", .CustomerID = 354}, _

        New Customer With {.ContactName = "Jane Doe", .CustomerID = 938}}

     

    Dim OrderTable As Order() = { _

        New Order With {.OrderDate = #3/25/1982#, .CustomerID = 112}, _

        New Order With {.OrderDate = #3/13/2005#, .CustomerID = 112}, _

        New Order With {.OrderDate = #9/29/2007#, .CustomerID = 938}, _

        New Order With {.OrderDate = #1/31/2008#, .CustomerID = 444}}

     

    3. Write a query to produce the results of a SQL Left Join

     

    Actual Results:

     

    What I need to create is something like this:

     

    From Contact In CustomerTable _

    Group Join Shipment In OrderTable _

      On Contact.CustomerID Equals Shipment.CustomerID _

      Into RightTableResults = Group _

    From Shipment In RightTableResults.DefaultIfEmpty _

    Select Contact.ContactName, _

           OrderDate = _

             If(Shipment Is Nothing, Nothing, _

                If(Shipment Is Nothing, New Order, Shipment).OrderDate)

     

    Expected Results:

     

    What I'd like to create is something like this:

     

    From Contact In CustomerTable _

    Left Join Shipment In OrderTable _

      On Contact.CustomerID Equals Shipment.CustomerID

     

    and for Right Outer and Full Outer Joins:

     

    From Contact In CustomerTable _

    Right Join Shipment In OrderTable _

      On Contact.CustomerID Equals Shipment.CustomerID

     

    From Contact In CustomerTable _

    Full Outer Join Shipment In OrderTable _

      On Contact.CustomerID Equals Shipment.CustomerID

     

    Product Name and Version:

     

    Visual Studio .NET 2008 VSTS (or any other VB SKU)

    Tuesday, February 05, 2008 6:17 PM

All replies

  • Hello there, Bill

     

    Your idea was add extra join operators for the VB language. Unfortunately we found that we didn’t have enough extra time available in our next release of Visual Studio to fit these changes. Given the changing landscape and timeframe for the next release of Visual Studio after that, we will likely not do this work then either - so we’ve resolved this bug as Won’t Fix. Please feel free to reactivate this bug or email me at timng@microsoft.com if you feel that we’ve made the wrong decision.

     

    Thanks!

     

    Tim

    Friday, February 29, 2008 5:52 PM
  • Hello there, Bill

     

    Your idea was add extra join operators for the VB language. Unfortunately we found that we didn’t have enough extra time available in our next release of Visual Studio to fit these changes. Given the changing landscape and timeframe for the next release of Visual Studio after that, we will likely not do this work then either - so we’ve resolved this bug as Won’t Fix. Please feel free to reactivate this bug or email me at timng@microsoft.com if you feel that we’ve made the wrong decision.

     

    Thanks!

     

    Tim

     

    Friday, February 29, 2008 5:53 PM
  • Hello there, Bill

     

    Your idea was add extra join operators for the VB language. Unfortunately we found that we didn’t have enough extra time available in our next release of Visual Studio to fit these changes. Given the changing landscape and timeframe for the next release of Visual Studio after that, we will likely not do this work then either - so we’ve resolved this bug as Won’t Fix. Please feel free to reactivate this bug or email me at timng@microsoft.com if you feel that we’ve made the wrong decision.

     

    Thanks!

     

    Tim

    Saturday, March 01, 2008 11:26 PM
  •  

    Hello there, Bill

     

    Your idea was add extra join operators for the VB language. Unfortunately we found that we didn’t have enough extra time available in our next release of Visual Studio to fit these changes. Given the changing landscape and timeframe for the next release of Visual Studio after that, we will likely not do this work then either - so we’ve resolved this bug as Won’t Fix. Please feel free to reactivate this bug or email me at timng@microsoft.com if you feel that we’ve made the wrong decision.

     

    Thanks!

     

    Tim

    Saturday, March 01, 2008 11:35 PM
  • This issue has been resolved as Won't Fix.
    Saturday, March 01, 2008 11:46 PM
  • Over the past few months we’ve been running a pilot in these forums allowing you to submit bugs and suggestions to us directly.  We’ve learned a lot during this pilot and we’re enthusiastic about, and committed to, expanding our ability to take your feedback, and respond to it thoughtfully.  By now you’ve hopefully seen our announcement about our plans to migrate these forums to our brand new forums platform.  As a part of this migration we’re going to be closing down the bug and suggestion pilot program.  We’re going to take some time to analyze how well the pilot went, see what we need to tune up, and make sure that we build the right features into the new platform.

     

    We appreciate all of the feedback you’ve given us through this pilot, and while we work out how to bring this feature to the new forums, please continue to submit any bugs or suggestions you have through our Connect site here.

     

    If you have any questions or concerns about the bug and suggestion feedback pilot, please contact us.

     

    Thank You,

    Developer Division Community Connection

     

    Tuesday, May 13, 2008 11:59 PM