views:

415

answers:

1

I'm trying to use a discriminator field in my linq to sql setup. I have a base class called Inventory_Item which I have setup to be abstract and then many different services that inherit from it (e.g. BaseWash). Now the properties for the BaseWash association are

Base Class Discriminator Value    = 1
Derived Class Discriminator Value = 2
Discriminator Property = ItemCategoryID
Inheritance Default = BaseWash

This builds fine but when it runs I get an exception in the designer code here:

public System.Data.Linq.Table<Inventory_Item> Inventory_Items
{
    get
    {
        return this.GetTable<Inventory_Item>();
    }
}

Abstract class 'ICS.Core.Inventory_Item' should not be assigned an inheritance discriminator key.

What am I doing wrong?

+2  A: 

Since Inventory_Item is abstract, there is no way you can ever instantiate an Inventory_Item. So just clear the Base Class Discriminator Value - it can never be used. Or make the class non-abstract and leave it at 1.

Marc Gravell
Thanks that appears to have fixed my problem. Score another point for SO.
Mykroft