LightSwitch 2013 - Inheritance with WCFRIA RRS feed

  • Question

  • Hello,

    I'm building a LightSwitch 2013 HTML application.

    I'm using WCFRIA service.

    Inside my WCFRIA project, I have 3 WCFRIA classes: A,B,C.

    Class A is the base class. B and C inherit from A.

    How do i implement it?


    Thursday, December 1, 2016 10:20 AM

All replies

  • Anyone?
    Tuesday, December 6, 2016 7:05 AM
  • You can use an inheritance hierarchy for your RIA entities without a problem - say to abstract common properties into a base classs - but you still have to implement separate public query, insert, update and delete methods for each of those entities. LS doesn't care much for what happens inside the RIA service - that is, how you implement it on the inside - as long as it conforms to the above basic rules from the outside. Hope that helps.

    Regards, Xander. My Blog

    Monday, December 12, 2016 6:50 PM
  • Hello Xander,

    Thanks for your reply.

    Unfortunately, i didn't manage to do that.

    Can you please write a simple (and full) example with 2-3 classes?


    • Edited by Yaron Y Sunday, December 18, 2016 8:56 AM
    Wednesday, December 14, 2016 7:19 AM
  • Please.

    This is really important for me...

    Sunday, December 18, 2016 8:56 AM
  • you should be able to combine a simple article on 1) class inheritance with 2) RIA domain service in LS to get what you want. The only difference is that you will inherit your B and C entities from A using normal inheritance. The query, insert, update and delete methods are implemented as if A, B and C are separate entities. Perhaps the better question is why do you want to have inherited entities under this scenario?

    Regards, Xander. My Blog

    Sunday, December 18, 2016 4:07 PM
  • Hello again Xander.

    Thank you for your answer.

    I need to use inheritance because i have a class (A) and other classes (B,C,...) that have the same properties of A plus other properties.

    I'll give you an example of what i'm doing with 2 classes (A,B):

    namespace WCF_RIA_Project


         public class A



              public int A_ID {get;set;}

              public string name {get;set;}

              public int IDNumber {get;set;}


         public class B : A


               public int B_property {get;set;}


          public class WCF_RIA : DomainService

                  [Query(IsDefault = true)]
                  public IQueryable<A> A_DEFAULT()
                         return new List<A>().asQueryable();


                  [Query(IsDefault = true)]
                  public IQueryable<B> B_DEFAULT()
                         return new List<B>().asQueryable();



    Lightswitch force me to do a default query for each class, and at the same time, it tells me that i can't have 2 Queries from the same object.

    Please Please Please - Can you write an example (or send me a simple project) of inheritance in WCFRIA?


    Thursday, December 22, 2016 9:09 AM
  • I'm actually on vacation at the moment until end of January, without a computer, only have my iPad and phone. It is not obvious to me why the above is not working, but in my own RIA service with inheritance I had a common base class that was inherited from by all the entities. The only difference between that and what you are doing, is that I did not have a query method for the base class. Can you perhaps try the same by abstracting the common properties to a similar base class where you do not add a query method for that base class and do mint expose that base class directly?

    Regards, Xander. My Blog

    Thursday, December 22, 2016 4:27 PM
  • Hey Xander,

    I'm still stuck in this issue...

    Can you please send me your working example?


    Tuesday, February 21, 2017 9:55 AM