//------------------------------------------------------------------------------------------------------------------- private List <ArticleMediaItems> Init(string LogFilePath, string LogFileName, SqlCommand cmd) { SqlConnection con = db.getConnection(); cmd.Connection = con; List <ArticleMediaItems> l_ArticleMediaItems = new List <ArticleMediaItems>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); SmartDataReader smartReader = new SmartDataReader(reader); while (smartReader.Read()) { ArticleMediaItems m_ArticleMediaItems = new ArticleMediaItems(db.ConnectionString); m_ArticleMediaItems.ArticleMediaItemId = smartReader.GetInt32("ArticleMediaItemId"); m_ArticleMediaItems.ArticleId = smartReader.GetInt32("ArticleId"); m_ArticleMediaItems.MediaItemId = smartReader.GetInt32("MediaItemId"); m_ArticleMediaItems.CrUserId = smartReader.GetInt32("CrUserId"); m_ArticleMediaItems.CrDateTime = smartReader.GetDateTime("CrDateTime"); l_ArticleMediaItems.Add(m_ArticleMediaItems); } smartReader.disposeReader(reader); db.closeConnection(con); } catch (SqlException ex) { LogFiles.WriteLog(ex.Message, LogFilePath + "\\Exception", LogFileName + "." + this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name); } return(l_ArticleMediaItems); }
//-------------------------------------------------------------------------------------------------------------------- public ArticleMediaItems GetByMediaItemId(string LogFilePath, string LogFileName, int MediaItemId) { ArticleMediaItems RetVal = new ArticleMediaItems(db.ConnectionString); try { List <ArticleMediaItems> list = GetListByMediaItemId(LogFilePath, LogFileName, MediaItemId); if (list.Count > 0) { RetVal = (ArticleMediaItems)list[0]; } } catch (Exception ex) { LogFiles.WriteLog(ex.Message, LogFilePath + "\\Exception", LogFileName + "." + this.GetType().Name + "." + MethodBase.GetCurrentMethod().Name); } return(RetVal); }