public static TMSNews Get(System.Int64 nwId) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSNews instance; instance = new TMSNews(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSNews_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, nwId); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) { throw new ApplicationException("Could not get TMSNews ID:" + nwId.ToString() + " from Database."); } // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom(ds.Tables[0].Rows[0]); return(instance); }
public static TMSNews[] Search(System.Int64?nwId, System.String ndHeading, System.String ndImagePath, System.String ndDescription, System.DateTime?ndCreatedDate, System.Int32?ndStatus) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSNews_SEARCH"; dbCommand = db.GetStoredProcCommand(sqlCommand, nwId, ndHeading, ndImagePath, ndDescription, ndCreatedDate, ndStatus); ds = db.ExecuteDataSet(dbCommand); ds.Tables[0].TableName = TABLE_NAME; return(TMSNews.MapFrom(ds)); }
public static TMSNews[] MapFrom(DataSet ds) { List <TMSNews> objects; // Initialise Collection. objects = new List <TMSNews>(); // Validation. if (ds == null) { throw new ApplicationException("Cannot map to dataset null."); } else if (ds.Tables[TABLE_NAME].Rows.Count == 0) { return(objects.ToArray()); } if (ds.Tables[TABLE_NAME] == null) { throw new ApplicationException("Cannot find table [dbo].[TMS_News] in DataSet."); } if (ds.Tables[TABLE_NAME].Rows.Count < 1) { throw new ApplicationException("Table [dbo].[TMS_News] is empty."); } // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSNews instance = new TMSNews(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return(objects.ToArray()); }
public static TMSNews[] Search(TMSNews searchObject) { return(Search(searchObject.NwId, searchObject.NDHeading, searchObject.NDImagePath, searchObject.NDDescription, searchObject.NDCreatedDate, searchObject.NDStatus)); }
public static void Update(TMSNews tMSNews, DbTransaction transaction) { tMSNews.Update(transaction); }
public static void Update(TMSNews tMSNews) { tMSNews.Update(); }
public static DataSet GetSearch(TMSNews searchObject) { return GetSearch(searchObject.NwId, searchObject.NDHeading, searchObject.NDImagePath, searchObject.NDDescription, searchObject.NDCreatedDate, searchObject.NDStatus); }
public static void Update(TMSNews tMSNews, DbTransaction transaction) { tMSNews.Update(transaction); }
public static void Update(TMSNews tMSNews) { tMSNews.Update(); }
public static TMSNews[] MapFrom(DataSet ds) { List<TMSNews> objects; // Initialise Collection. objects = new List<TMSNews>(); // Validation. if (ds == null) throw new ApplicationException("Cannot map to dataset null."); else if (ds.Tables[TABLE_NAME].Rows.Count == 0) return objects.ToArray(); if (ds.Tables[TABLE_NAME] == null) throw new ApplicationException("Cannot find table [dbo].[TMS_News] in DataSet."); if (ds.Tables[TABLE_NAME].Rows.Count < 1) throw new ApplicationException("Table [dbo].[TMS_News] is empty."); // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSNews instance = new TMSNews(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return objects.ToArray(); }
public static TMSNews Get(System.Int64 nwId) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSNews instance; instance = new TMSNews(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSNews_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, nwId); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) throw new ApplicationException("Could not get TMSNews ID:" + nwId.ToString()+ " from Database."); // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom( ds.Tables[0].Rows[0] ); return instance; }