initial commit
This commit is contained in:
37
Data/AttachmentData.cs
Normal file
37
Data/AttachmentData.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user