private void ConvertToModel(IDataReader reader, OutCourseInfo model) { if (reader["Id"] != DBNull.Value) model.Id = Convert.ToInt32(reader["Id"]); if (reader["OutSideType"] != DBNull.Value) model.OutSideType = Convert.ToInt32(reader["OutSideType"]); if (reader["OutSideLink"] != DBNull.Value) model.OutSideLink = reader["OutSideLink"].ToString(); if (reader["OutSideContent"] != DBNull.Value) model.OutSideContent = reader["OutSideContent"].ToString(); if (reader["OutCourseTitle"] != DBNull.Value) model.OutCourseTitle = reader["OutCourseTitle"].ToString(); if (reader["OutCourseLink"] != DBNull.Value) model.OutCourseLink = reader["OutCourseLink"].ToString(); if (reader["DisplayEnterBtn"] != DBNull.Value) model.DisplayEnterBtn = Convert.ToBoolean(reader["DisplayEnterBtn"]); }
/// <summary> /// 取得外部课程信息 /// </summary> /// <param name="where"></param> /// <returns></returns> public OutCourseInfo GetOutCourse(string where) { StringBuilder sql = new StringBuilder(); sql.Append("select A.Id,A.OutSideType,A.OutSideLink,A.OutSideContent,"); sql.Append("B.Title as OutCourseTitle,B.Link as OutCourseLink,B.DisplayEnterBtn"); sql.Append(" from Traning_Detail A"); sql.Append(" join Traning_OutCourseType B on A.OutSideType=B.Id"); if (!string.IsNullOrEmpty(where)) sql.Append(" where " + where); using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql.ToString())) { if (reader.Read()) { OutCourseInfo model = new OutCourseInfo(); ConvertToModel(reader, model); return model; } else { return null; } } }