Files
LibraryWeb/Data/AttachmentData.cs
2026-08-04 14:41:21 +03:00

38 lines
1008 B
C#

using System.Collections.Generic;
using Microsoft.Data.SqlClient;
namespace Library;
public class AttachmentData
{
public int ID { init; get; } = 0;
public string Title { init; get; } = null!;
public string? UUID { init; get; } = null;
public string? Link { init; get; } = null;
public string? Format { init; get; } = null;
public static List<AttachmentData> GetList( SqlConnection connection , int repository_id )
{
using SqlDataReader reader = new SQLBuilder( connection , "SELECT * FROM [v_attachment] WHERE repository_id = @repository_id" )
.AddParameter( "@repository_id" , repository_id )
.ExecuteReader( );
List<AttachmentData> result = new( );
while ( reader.Read( ) )
{
AttachmentData attachment = new( )
{
ID = reader.Int( "id" ) ,
UUID = reader.StringSafe( "uuid" ) ,
Title = reader.StringSafe( "title" ) ,
Link = reader.StringSafe( "link" ) ,
Format = reader.String( "format" ) ,
};
result.Add( attachment );
}
return result;
}
}