using System; using System.Data; using System.Linq; using ChaosBot.Attribute; using ChaosBot.Database; namespace ChaosBot.Database.Entity { public abstract class BaseEntity { protected BaseEntity() {} public abstract void SetFromRow(DataRow row); protected static QueryBuilder Query() where T : BaseEntity, new() { var dbEntityAttribute = typeof(T).GetCustomAttributes( typeof(DBEntity), true ).FirstOrDefault() as DBEntity; if (dbEntityAttribute != null) { return new QueryBuilder(dbEntityAttribute.Table); } throw new SystemException($"Class {typeof(T)} does not have an attribute of {typeof(DBEntity)} set"); } } }