/
TableAttribute.cs
46 lines (41 loc) · 1.36 KB
/
TableAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace System.ComponentModel.DataAnnotations.Schema
{
/// <summary>
/// Specifies the database table that a class is mapped to.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class TableAttribute : Attribute
{
private string? _schema;
/// <summary>
/// Initializes a new instance of the <see cref="TableAttribute" /> class.
/// </summary>
/// <param name="name">The name of the table the class is mapped to.</param>
public TableAttribute(string name)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
Name = name;
}
/// <summary>
/// The name of the table the class is mapped to.
/// </summary>
public string Name { get; }
/// <summary>
/// The schema of the table the class is mapped to.
/// </summary>
[DisallowNull]
public string? Schema
{
get => _schema;
set
{
ArgumentException.ThrowIfNullOrWhiteSpace(value);
_schema = value;
}
}
}
}