-
Notifications
You must be signed in to change notification settings - Fork 0
/
TableName.cs
52 lines (45 loc) · 1.12 KB
/
TableName.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
47
48
49
50
51
52
namespace CopyDb
{
class TableName
{
public readonly string Schema;
public readonly string Name;
public TableName(string schema, string name)
{
Schema = schema;
Name = name;
}
public override string ToString()
{
return FullyQualifiedName;
}
public string FullyQualifiedName
{
get { return Quoted(Schema) + "." + Quoted(Name); }
}
private string Quoted(string name)
{
return "[" + name.Replace("]", "]]") + "]";
}
public bool Equals(TableName other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Equals(other.Schema, Schema) && Equals(other.Name, Name);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != typeof(TableName)) return false;
return Equals((TableName) obj);
}
public override int GetHashCode()
{
unchecked
{
return ((Schema != null ? Schema.GetHashCode() : 0)*397) ^ (Name != null ? Name.GetHashCode() : 0);
}
}
}
}