c# - 3 tables, 3 classes, help designing my classes effectively -


I have 3 database tables, all of them have 5 columns. They are different in that table # 2 and each of the table # 3 has another ID column.

I do not want to create 3 different classes for this, but the problem is in my Database Assistant category, a method that loads classes like:

  public static load class 1 (SqlDataReader Reader) {Class 1C1 = New Class 1 (); C1.prop1 = (int) reader ["prop1"]}  

I do not have to create 3 different load supportive methods, and all of them have to copy the code to them. (I do not feel like making 3, but only each has to set different fields).

Four methods: one and three others who load the main field, call the core method and Load additional fields. It will work best with a base class with core properties, and 3 subclasses.

Int field2; Int field3; Int field4; Int field5; } Public square all 1: core {field 6; } ... public static zero loadcore (core c, datatelle dt) {c.field1 = dt.getField1 (); // in fact a database value c.field2 = dt.getField2 (); C.field3 = dt.getField3 (); C.field4 = dt.getField4 (); C.field5 = dt.getField5 (); } Public Fixed Sub1 LoadSub1 () {All 1s = new all 1 (); Loadcore (S, MIDATATABLE); S.field6 = MY_DATA_TABLE.getField6 (); }


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -