locked
decoupling complex entity classes from business specific data RRS feed

  • Question

  • User182605048 posted

    There is a case/functionality where we are using entity class/es which contain data contracts (properties - simple and complex) specific to a particular business task. But now, we want to generalize the case/functionality to any business task. We thought about two ways -

    1) Can it be possible to generalize the entity class/es? If so, how to know what are the specific properties of each business task (can be xml)?

    2) To use a better store than entity class/es and ofcourse to use xml to specify the properties for each business task.

    I am not sure how to approach this problem as these are very vague thoughts and if they actually will help solve the problem.

    Example of specific existing entity classes:

    public class TestInput
        {
            private string m_MStatus = "";
            private int m_ND = 0;
            private string m_MCode = "";
            private string m_State = "";
            private string m_RFilePath = "";
            private Extrcat extrcatDetails;
            private TransType m_TransType;

            [DataMember]
            public TransType TransT
            {  get; set;        }

            [DataMember]
            public Extrcat Extrc
            {  get; set;        }

            [DataMember]
            public string State
            {         get; set;        }

            [DataMember]
            public string MCode
            {     get; set; }

            [DataMember]
            public int ND
            {            get; set;        }

            [DataMember]
            public string MStatus
            {           get; set;        }

            [DataMember]
            public string RFilePath
            {            get; set;        }
        }

    class Extrcat

    {

    List<Extr> m_ExtrList = null;

    public Extrcat() {

    m_ExtrList = new List<Extr>();

    }

    ...................

    }

    The properties in above classes (including count) change for different business tasks. But we dont want to create entity classes for each business task and want to provide a generic solution for any business task, taking away specifics outside. How to go about it?

    Friday, March 8, 2013 5:29 AM

All replies

  • User182605048 posted

    The solution I tried to develop is to use XML to define the process and specifics of business flow and data, use Dictionary to replace entities. I thought of using ExpandoObject to replace entity class, but it defines the properties at compile time and that spoils the generalization. So Dictionary was used.

    By traversing through the XML and storing data in Dictionary/s, I was able to generalize my business tasks.

    Tuesday, March 19, 2013 8:48 AM