예제 #1
0
        public List <DEPARTMENT_OBJ> FillToOBJ(DataSet ds)
        {
            List <DEPARTMENT_OBJ> lidata = new List <DEPARTMENT_OBJ>();

            foreach (DataRow dr in ds.Tables["Tmp"].Rows)
            {
                DEPARTMENT_OBJ obj = new DEPARTMENT_OBJ();

                Type myTableObject = typeof(DEPARTMENT_OBJ);
                System.Reflection.PropertyInfo[] selectFieldInfo = myTableObject.GetProperties();

                Type myObjectType = typeof(DEPARTMENT_OBJ);
                System.Reflection.PropertyInfo[] fieldInfo = myObjectType.GetProperties();

                //set object value
                foreach (System.Reflection.PropertyInfo info in selectFieldInfo)
                {
                    if (info.Name != "_ID")
                    {
                        if (dr.Table.Columns.Contains(info.Name))
                        {
                            if (!dr.IsNull(info.Name))
                            {
                                info.SetValue(obj, dr[info.Name], null);
                            }
                        }
                    }
                    else
                    {
                        //set id value
                        DEPARTMENT_OBJ objid;
                        objid = (DEPARTMENT_OBJ)info.GetValue(obj, null);
                        foreach (System.Reflection.PropertyInfo info1 in fieldInfo)
                        {
                            if (dr.Table.Columns.Contains(info1.Name))
                            {
                                info1.SetValue(objid, dr[info1.Name], null);
                            }
                        }
                        info.SetValue(obj, objid, null);
                    }
                }
                lidata.Add(obj);
            }
            return(lidata);
        }
예제 #2
0
        public DEPARTMENT_OBJ createObject()
        {
            DEPARTMENT_OBJ obj = new DEPARTMENT_OBJ();

            return(obj);
        }