forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReferenceDependantValue.cs
40 lines (35 loc) · 1001 Bytes
/
ReferenceDependantValue.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
using System;
using System.Collections.Generic;
namespace NHibernate.Mapping
{
/// <summary>
///
/// </summary>
[Serializable]
public class ReferenceDependantValue : DependantValue
{
private readonly SimpleValue _prototype;
public ReferenceDependantValue(Table table, SimpleValue prototype)
: base(table, prototype)
{
_prototype = prototype;
}
public IEnumerable<Column> ReferenceColumns
{
get { return _prototype.ConstraintColumns; }
}
public override void CreateForeignKeyOfEntity(string entityName)
{
if (!HasFormula && !string.Equals("none", ForeignKeyName, StringComparison.OrdinalIgnoreCase))
{
var referencedColumns = new List<Column>(_prototype.ColumnSpan);
foreach (Column column in _prototype.ColumnIterator)
{
referencedColumns.Add(column);
}
ForeignKey fk = Table.CreateForeignKey(ForeignKeyName, ConstraintColumns, entityName, referencedColumns);
fk.CascadeDeleteEnabled = IsCascadeDeleteEnabled;
}
}
}
}