public List <section> load_sections(int?id = null, int?id_ms = null) { List <section> res = new List <section>(); foreach (DataRow ra in dt_sections(id, id_ms).Rows) { int section_id = db_provider.int_val(ra["section_id"]); section s = res.FirstOrDefault(x => x.id == section_id); if (s == null) { s = section_from_dr(ra); res.Add(s); } string attribute_code = db_provider.str_val(ra["attribute_code"]); if (attribute_code != "") { string attribute_type = db_provider.str_val(ra["attribute_type"]); object val = ra["val_" + attribute_type] != DBNull.Value ? ra["val_" + attribute_type] : null; s.set_attribute(attribute_code , (section_attr.section_attr_type)Enum.Parse(typeof(section_attr.section_attr_type), attribute_type), val); } } return(res); }
public section add_section(section s) { sections.Add(s); return(s); }