public static TMSGraceDetails Get(System.Int64 gdGraceId) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSGraceDetails instance; instance = new TMSGraceDetails(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSGraceDetails_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, gdGraceId); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) { throw new ApplicationException("Could not get TMSGraceDetails ID:" + gdGraceId.ToString() + " from Database."); } // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom(ds.Tables[0].Rows[0]); return(instance); }
public static TMSGraceDetails[] Search(System.Int64?gdGraceId, System.Int64?gdSchoolId, System.Int64?sdSubjectId, System.String sdGraceMarks, System.DateTime?sdDate, System.Int32?sdStatus) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSGraceDetails_SEARCH"; dbCommand = db.GetStoredProcCommand(sqlCommand, gdGraceId, gdSchoolId, sdSubjectId, sdGraceMarks, sdDate, sdStatus); ds = db.ExecuteDataSet(dbCommand); ds.Tables[0].TableName = TABLE_NAME; return(TMSGraceDetails.MapFrom(ds)); }
public static TMSGraceDetails[] MapFrom(DataSet ds) { List <TMSGraceDetails> objects; // Initialise Collection. objects = new List <TMSGraceDetails>(); // 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_GraceDetails] in DataSet."); } if (ds.Tables[TABLE_NAME].Rows.Count < 1) { throw new ApplicationException("Table [dbo].[TMS_GraceDetails] is empty."); } // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSGraceDetails instance = new TMSGraceDetails(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return(objects.ToArray()); }