public static TMSWorkToDo Get(System.Int64 wdId) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSWorkToDo instance; instance = new TMSWorkToDo(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSWorkToDo_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, wdId); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) { throw new ApplicationException("Could not get TMSWorkToDo ID:" + wdId.ToString() + " from Database."); } // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom(ds.Tables[0].Rows[0]); return(instance); }
public static TMSWorkToDo[] Search(System.Int64?wdId, System.String wdTitle, System.String wdReason, System.String wdPriority, System.DateTime?wdWorkDate, System.String wdTime, System.String wdWorkStatus, System.String wdExtra, System.DateTime?wdDate, System.Int32?wdStatus) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSWorkToDo_SEARCH"; dbCommand = db.GetStoredProcCommand(sqlCommand, wdId, wdTitle, wdReason, wdPriority, wdWorkDate, wdTime, wdWorkStatus, wdExtra, wdDate, wdStatus); ds = db.ExecuteDataSet(dbCommand); ds.Tables[0].TableName = TABLE_NAME; return(TMSWorkToDo.MapFrom(ds)); }
public static TMSWorkToDo[] MapFrom(DataSet ds) { List <TMSWorkToDo> objects; // Initialise Collection. objects = new List <TMSWorkToDo>(); // 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_WorkToDo] in DataSet."); } if (ds.Tables[TABLE_NAME].Rows.Count < 1) { throw new ApplicationException("Table [dbo].[TMS_WorkToDo] is empty."); } // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSWorkToDo instance = new TMSWorkToDo(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return(objects.ToArray()); }
public static TMSWorkToDo[] MapFrom(DataSet ds) { List<TMSWorkToDo> objects; // Initialise Collection. objects = new List<TMSWorkToDo>(); // 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_WorkToDo] in DataSet."); if (ds.Tables[TABLE_NAME].Rows.Count < 1) throw new ApplicationException("Table [dbo].[TMS_WorkToDo] is empty."); // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSWorkToDo instance = new TMSWorkToDo(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return objects.ToArray(); }
public static TMSWorkToDo Get(System.Int64 wdId) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSWorkToDo instance; instance = new TMSWorkToDo(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSWorkToDo_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, wdId); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) throw new ApplicationException("Could not get TMSWorkToDo ID:" + wdId.ToString()+ " from Database."); // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom( ds.Tables[0].Rows[0] ); return instance; }