locked
Not an entity type error - reflection provider with inherited class RRS feed

  • Question

  • Hi,

    We have custom libraries that have something like:

    public class OrderBase
    {
        public string Id {get; set;}
    }

    [DataServiceKeyAttribute("Id")]
    public partial class Order: OrderBase
    {
    }

    When exposing to WCF data services.

    public class OrderContext
    {
        public IQueryable<Order> Orders() { ... }
    }

    The exception message is 'On data context type 'OrderContext', there is a top IQueryable property 'Order' whose element type is not an entity type.

    Is there a solution for this error?

     Thanks,

    yysun

    Monday, April 26, 2010 9:08 PM

Answers

  • The ID property has to be declared on the base type, not the derived type.

    Change your classes to be :

    [DataServiceKeyAttribute("Id")]
    public class OrderBase
    {
        public string Id {get; set;}
    }

    public partial class Order: OrderBase
    {
    }

     


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Monday, April 26, 2010 9:27 PM
    Moderator

All replies

  • The ID property has to be declared on the base type, not the derived type.

    Change your classes to be :

    [DataServiceKeyAttribute("Id")]
    public class OrderBase
    {
        public string Id {get; set;}
    }

    public partial class Order: OrderBase
    {
    }

     


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Monday, April 26, 2010 9:27 PM
    Moderator
  • It works to by moving DataServiceKeyAttribute to the base class. Thanks.
    Monday, April 26, 2010 11:24 PM