VB 9.0 Version of LINQ to DataSets Won't Accept Nullable(Of Type) or Type? of DataTable Field - by Roger Jennings

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 286904 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 7/11/2007 10:27:00 AM
Access Restriction Public


Please nuke this bug report. I forgot to add the Of preposition in both cases.

With a typed DataSet created from the Northwind Customers, Orders, Order Details and Products table, the following C# 3.0 code will compile and run correctly in Beta 1 and June 2007 CTP:

var query = from c in dsNwindT.Customers
                   join o in dsNwindT.Orders on c.CustomerID equals o.CustomerID
                   join d in dsNwindT.Order_Details on o.OrderID equals d.OrderID
                   join p in dsNwindT.Products on d.ProductID equals p.ProductID
                   where p.ProductID == 2 && c.Country == "USA"
                            orderby o.OrderID descending
                   select new { c.CustomerID, c.CompanyName, o.OrderID,
                            ShippedDate = o.Field<DateTime?>("ShippedDate"), 
                            p.ProductName, d.Quantity };

foreach (var q in query) 

The following VB 9.0 code won't compile in the Orcas June 2007 CTP because o.Field(DateTime?)("ShippedDate") reports an error (cannot use ? at this location) or o.Field(Nullable Of(DateTime))("ShippedDate") reports an error (is a type).

Dim Query = From c In dsNwindT.Customers _
                    Join o In dsNwindT.Orders On c.CustomerID Equals o.CustomerID _
                    Join d In dsNwindT.Order_Details On o.OrderID Equals d.OrderID _
                    Join p In dsNwindT.Products On d.ProductID Equals p.ProductID _
                    Where p.ProductID = 2 AndAlso c.Country = "USA" _
                    Order By o.OrderID Descending _
                    Select c.CustomerID, c.CompanyName, o.OrderID, _
                       ShippedDate = o.Field(Nullable(Of DateTime))("ShippedDate"), _
                       p.ProductName, d.Quantity

For Each q In Query

The preceding code works with:

 ShippedDate = o.Field(Of Nullable(Of DateTime))("ShippedDate"), _


 ShippedDate = o.Field(Of DateTime?)("ShippedDate"), _

Zipped C# and VB code files are attached. The correct file is EFLinqJuneCTPSamples.zip (The other was uploaded in error).
Sign in to post a comment.
Posted by Microsoft on 7/13/2007 at 6:33 PM
Hi Roger,

This isn't reproing for me on current builds, but the issue might be that you were missing an "Of" before Nullable(Of DateTime). I tried changing it to "Of DateTime?" and everything still compiled fine.

If you're still seeing this once Beta2 ships please let us know exactly what error message you're seeing and we'll be happy to look at it again.


Jonathan Aneja
Program Manager
VB Team
Posted by Roger Jennings on 7/12/2007 at 11:50 AM
Please nuke this bug report. I forgot to add the Of preposition in both cases.

Bill McCarthy set me straight.

Posted by Microsoft on 7/11/2007 at 9:33 PM
Thanks for your feedback. We have reproduced this bug on Visual Studio Codename Orcas June CTP, and we are sending this bug to the appropriate group within the VisualStudio Product Team for triage and resolution.

Thank you,
Visual Studio Product Team.
Posted by Microsoft on 7/11/2007 at 4:42 PM
Thank you for your feedback. We are currently investigating. If this issue is urgent, please call support directly (see http://support.microsoft.com).

Thank you,
Visual Studio Product Team