Пример #1
0
        public List <C_Department> GetDepartments()
        {
            var entities = new List <C_Department>();

            using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Rs.Sql_C_Department_Repository_GetDepartments, null)) {
                while (rdr.Read())
                {
                    var entity = new C_Department();
                    entity.Id       = SqlTypeConverter.DBNullStringHandler(rdr["Id"]);
                    entity.Code     = SqlTypeConverter.DBNullStringHandler(rdr["Code"]);
                    entity.Name     = SqlTypeConverter.DBNullStringHandler(rdr["Name"]);
                    entity.ParentId = SqlTypeConverter.DBNullStringHandler(rdr["ParentId"]);
                    entity.Comment  = SqlTypeConverter.DBNullStringHandler(rdr["Desc"]);
                    entity.Enabled  = SqlTypeConverter.DBNullBooleanHandler(rdr["Enabled"]);
                    entities.Add(entity);
                }
            }
            return(entities);
        }
Пример #2
0
        public C_Department GetDepartmentByCode(string code)
        {
            SqlParameter[] parms = { new SqlParameter("@Code", SqlDbType.VarChar, 50) };
            parms[0].Value = SqlTypeConverter.DBNullStringChecker(code);

            C_Department entity = null;

            using (var rdr = SqlHelper.ExecuteReader(this._databaseConnectionString, CommandType.Text, SqlCommands_Rs.Sql_C_Department_Repository_GetDepartmentByCode, parms)) {
                if (rdr.Read())
                {
                    entity          = new C_Department();
                    entity.Id       = SqlTypeConverter.DBNullStringHandler(rdr["Id"]);
                    entity.Code     = SqlTypeConverter.DBNullStringHandler(rdr["Code"]);
                    entity.Name     = SqlTypeConverter.DBNullStringHandler(rdr["Name"]);
                    entity.ParentId = SqlTypeConverter.DBNullStringHandler(rdr["ParentId"]);
                    entity.Comment  = SqlTypeConverter.DBNullStringHandler(rdr["Desc"]);
                    entity.Enabled  = SqlTypeConverter.DBNullBooleanHandler(rdr["Enabled"]);
                }
            }
            return(entity);
        }