public static Attachment GetAttachment(IDatabaseProvider db, int id) { if (db == null) { throw new ArgumentNullException(nameof(db)); } AttachmentsTableAdapter tableAdapter = db.DB.AttachmentsTableAdapter; PeygirDatabaseDataSet.AttachmentsDataTable rows = tableAdapter.GetDataByID(id); if (rows.Count == 1) { // Found. Attachment attachment = new Attachment(rows[0]); return(attachment); } // Not found. return(null); }
public static Attachment[] GetAttachments(IDatabaseProvider db) { if (db == null) { throw new ArgumentNullException(nameof(db)); } AttachmentsTableAdapter tableAdapter = db.DB.AttachmentsTableAdapter; PeygirDatabaseDataSet.AttachmentsDataTable rows = tableAdapter.GetData(); // Create list. List <Attachment> attachments = new List <Attachment>(); foreach (var row in rows) { // Add. Attachment attachment = new Attachment(row); attachments.Add(attachment); } return(attachments.ToArray()); }