mirror of
https://github.com/Wincent01/InfectedRose.git
synced 2026-01-05 20:04:59 -06:00
21 lines
545 B
C#
21 lines
545 B
C#
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Reflection;
|
|
|
|
namespace InfectedRose.Database.Generic
|
|
{
|
|
public static class TableExtensions
|
|
{
|
|
public static TypedTable<T> Typed<T>(this AccessDatabase @this) where T : class
|
|
{
|
|
var type = typeof(T);
|
|
|
|
var attribute = type.GetCustomAttribute<TableAttribute>();
|
|
|
|
var id = attribute?.Name ?? type.Name;
|
|
|
|
var table = @this[id];
|
|
|
|
return new TypedTable<T>(table.Info, table.Data, @this);
|
|
}
|
|
}
|
|
} |