jonpryor / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
0 stars 0 forks source link

Exception with Anonymous Type and Association with a Nullable Value Type #248

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1.
Create two table. Items and Category.
The table Items has a foreign-key to Category that can be nullable.
Example: Item.CategoryId that maps to Category.Id
The association is one-to-many. DataType: Int32

2.
Create the relative DBML file with the association:
Table Items
      <Association Name="Category_Item" Member="Category" ThisKey="CategoryId"
OtherKey="Id" Type="Category" IsForeignKey="true" />
Table Category
      <Association Name="Category_Item" Member="Items" ThisKey="Id"
OtherKey="CategoryId" Type="Item" />

and generate the source code file.

3. Execute a simple query like this:
            var items = from i in db.Items
                         select new
                         {
                             i.Id,
                             i.Category
                         };

When the query is executed i get a InvalidOperationException: "nullable
object must have a value".

I'm using DbLinq-0.20.1.

Original issue reported on code.google.com by Bon...@gmail.com on 28 Apr 2010 at 10:42

GoogleCodeExporter commented 9 years ago
Sorry, i forgot to mention that i'm using MySQL Provider

Original comment by Bon...@gmail.com on 28 Apr 2010 at 12:56