using Apewer.Internals;
using System;
using System.Collections.Generic;
using System.Text;
namespace Apewer.Source
{
/// 数据库中的表。
[Serializable]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
public sealed class TableAttribute : Attribute
{
private string _name;
private bool _allprops = false;
private bool _independent = false;
///
public TableAttribute(string name = null, bool allProperties = false)
{
_name = TableStructure.RestrictName(name, string.IsNullOrEmpty(name));
_allprops = allProperties;
}
/// 表名。
public string Name
{
get => _name;
set => _name = TableStructure.RestrictName(value, false);
}
///
public bool Independent
{
get => _independent;
internal set => _independent = value;
}
/// 使用所有属性,即使属性不带有 Column 特性。
public bool AllProperties
{
get => _allprops;
set => _allprops = value;
}
///
public override int GetHashCode() => _name.GetHashCode();
}
}