none
C# Classes in well organized way - Need help RRS feed

  • Question

  • Hi Team,

    I have one requirement in C#, explained below.

    Each this entity class is a table and its properties are columns of that table

    EntityClass1

    EntityClass2

    EntityClass3

    EntityClass4

    EntityClass5

    EntityClass6

    EntityClass7

    EntityClass8

    EntityClass9

    EntityClass10

    Each DataSet is a class that should have access to properties of few entity classes listed above

    For example

    Dataset 1 should have access to properties of EntityClass1, EntityClass2, EntityClass3, EntityClass4, EntityClass5, EntityClass10

    Dataset 2 should have access to properties of EntityClass1, EntityClass2, EntityClass4, EntityClass6, EntityClass8

    Dataset 3 should have access to properties of EntityClass10,EntityClass9, EntityClass8, EntityClass6, EntityClass5

    This above setup should be available in a web service. I want to return the data set to the webUI as I have already said each dataset is a class.

    I cannot do the multiple inheritance as C# doesn’t support for multiple inheritance so the below line is not possible

    Public class Dataset: EntityClass1, EntityClass2, EntityClass3, EntityClass4,EntityClass5,EntityClass10

    I cannot use the Entity classes as Interface the reason is after I inherit I have to implement the properties again in my dataset class.

    I do not want to write the duplicate properties in each of my Dataset class.

    Can someone please help me?

    Thanks

    Selva


    Selvakumar Rathinam Team Lead

    Wednesday, May 8, 2013 8:33 AM

Answers

  • Maybe this would do it. Create a class DataSetSuper that contains fields (or properties) for entities that occur in all of DataSet1, DataSet2 etc (i.e. holds common entities).
    Then for DataSet1, etc, have a field (or property) that is of type DataSetSuper and fields for Entities specific to DataSet1.

    Essentially include the entities rather than inherit the.


    Regards David R
    ---------------------------------------------------------------
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
    Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
    Every program eventually becomes rococo, and then rubble. - Alan Perlis
    The only valid measurement of code quality: WTFs/minute.

    Wednesday, May 8, 2013 10:48 AM