public static TMSBookDetails Get(System.Int64 bdDetailsId) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSBookDetails instance; instance = new TMSBookDetails(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSBookDetails_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, bdDetailsId); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) { throw new ApplicationException("Could not get TMSBookDetails ID:" + bdDetailsId.ToString() + " from Database."); } // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom(ds.Tables[0].Rows[0]); return(instance); }
public static TMSBookDetails[] Search(System.Int64?bdDetailsId, System.String bdBookId, System.Int64?bdLibraryManagerId, System.String bdBookType, System.Int64?bdSubjectId, System.Int64?bdSchoolId, System.String bdBookName, System.String bdPublication, System.String bdAuthor, System.String bdTotalCopies, System.String bdAvailableCopies, System.String bdPerCopyCost, System.String bdTotalCost, System.String bdFor, System.String bdDescription, System.DateTime?bdDate, System.Int32?bdStatus) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSBookDetails_SEARCH"; dbCommand = db.GetStoredProcCommand(sqlCommand, bdDetailsId, bdBookId, bdLibraryManagerId, bdBookType, bdSubjectId, bdSchoolId, bdBookName, bdPublication, bdAuthor, bdTotalCopies, bdAvailableCopies, bdPerCopyCost, bdTotalCost, bdFor, bdDescription, bdDate, bdStatus); ds = db.ExecuteDataSet(dbCommand); ds.Tables[0].TableName = TABLE_NAME; return(TMSBookDetails.MapFrom(ds)); }
public static TMSBookDetails[] MapFrom(DataSet ds) { List <TMSBookDetails> objects; // Initialise Collection. objects = new List <TMSBookDetails>(); // 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_BookDetails] in DataSet."); } if (ds.Tables[TABLE_NAME].Rows.Count < 1) { throw new ApplicationException("Table [dbo].[TMS_BookDetails] is empty."); } // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSBookDetails instance = new TMSBookDetails(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return(objects.ToArray()); }