DLinq Designer and class inheritance

I've got a table set up for class inheritance, as discussed in the DLinq Overview for C# Developers. Now I can't figure out how to get DLinq Designer to generate the different classes for me. I've got a Contact table with a DiscKey varchar(1). When 'C', it's a company. When 'P', it's a person. So I should have a Contact class, a Company class, and a Person class, where Company and Person derive from Contact.

I haven't been able to figure out how to get the DLinq Designer to do this. Can anyone help

-Eric Harmon



Answer this question

DLinq Designer and class inheritance

  • TarPista

    Jim,

    I'm a little confused about where the entity stuff fits into the overall scheme of things. Is it an alternative to Linq Is it more link Linq for Entities (ELinq ) Is it effectively Linq 2.0 It seems *very* similar to the DLinq stuff now, in that database queries give you back objects. Can you shed a little light on how this all fits together

    -Eric


  • white2grey

    I have the same inheriting and virtual methods design and problem with Eric, I search all over the web now, no answer! I want to do it either by design or manually coded.

    Please help



  • DroopyPawn

    From the sounds of the polymorphic behavior you are trying to achieve, you may want to check out the ADO vNext CTP which offers the first look at LINQ to Entities which is being positioned to address that space. Unfortunately the CTP did not come with the designers, but there is a preview release of a designer you can try out. Give them a shot and let us know how well they work for you.

    Jim Wooley
    http://devauthority.com/blogs/jwooley



  • tomc1

    From reading the docs more closely, I see that multiple-level inheritance *is* supported. However, it doesn't look like the designer is correctly generating the code. In my case, it will generate the Client class as a derived class of the Person class, but it doesn't add the necessary attribute to the Contact class. It generates the attributes as:

    [System.Data.DLinq.InheritanceMapping(Code="X", Type=typeof(Contact), IsDefault=true)]

    [System.Data.DLinq.InheritanceMapping(Code="C", Type=typeof(Company))]

    [System.Data.DLinq.InheritanceMapping(Code="P", Type=typeof(Person))]

    [System.Data.DLinq.Table(Name="Contact")]

    So it creates an attribute for the immediate descendants of Contact, but it doesn't generate one for the descendant of Person.

    -Eric Harmon


  • Paul Sanders

    OK, I figured out the designer. However, I can't seem to add multiple levels of inheritance. I want to create a DiscKey where C = company, P=person, and X = Client, for example. Person derives from Contact (the base record, which I will never create any of), and then Client derives from Person. I don't seem to be able to derive Client from Person.

    If this can be done, could someone please point out how to do it Otherwise, I'd like to request this feature.

    -Eric Harmon


  • Stéphane Beauchemin

    From the list of attributes you are showing it looks like you are using the prototype designer + dlinq from May2006 CTP. You may have better luck with the designer in the Feb2007 Orcas CTP.

  • DLinq Designer and class inheritance