locked
Help! Data Services thinks my Entity as Complex Type. Why ? RRS feed

  • Question

  • Hi,

    I am new to Data Services and I am having problem with very basic bidirectional association. I  use in memory objects thus Reflection provider

    I have the following classes :

        [DataServiceEntity]
        [DataServiceKey("ID")]
        public class A
        {
            public int ID { get; set; }
            public B B { get; set; }
            
        }
    
        [DataServiceEntity]
        [DataServiceKey("ID")]
        public class B
        {
            
            public int ID { get; set; }
            public A A { get; set; }
        }

    Then from my method I return something like this:

        public IQueryable<A> A
        {
      	get
     	{
                   
             var a = new A { ID = 1 };
             var b = new B { ID = 2, A = a };
             a.B = b;
             return new List<A> { a }.AsQueryable();
    	}
        }

    When I hit to my browser, to get list of A's, I get the following error:

    The server encountered an error processing the request. The exception message is 'The property 'A' on a complex type 'B' is not a valid property. Navigation properties are not supported on complex types.'.

    But they have both ID's Why they are considered as complex types ? How can I make them entity types ?


    • Edited by onurg Wednesday, July 31, 2013 7:53 AM
    Wednesday, July 31, 2013 7:53 AM