DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
ForeignKeyAttribute.cs
Go to the documentation of this file.
1 using System;
2 
3 using Deveel.Data.Sql;
4 using Deveel.Data.Sql.Tables;
5 
6 namespace Deveel.Data.Mapping {
7  [AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property)]
8  public sealed class ForeignKeyAttribute : Attribute, INamedConstraint {
9  // constructors for class attributes...
10  public ForeignKeyAttribute(string name, Type referencedType, ForeignKeyAction onUpdate, ForeignKeyAction onDelete) {
11  ConstraintName = name;
12  ReferencedType = referencedType;
13  OnUpdate = onUpdate;
14  OnDelete = onDelete;
15  }
16 
17  public ForeignKeyAttribute(Type referencedType, ForeignKeyAction onUpdate, ForeignKeyAction onDelete)
18  : this(null, referencedType, onUpdate, onDelete) {
19  }
20 
21  public ForeignKeyAttribute(string name, Type referencedType)
22  : this(name, referencedType, ForeignKeyAction.Cascade, ForeignKeyAction.Cascade) {
23  }
24 
25  public ForeignKeyAttribute(Type referencedType)
26  : this(null, referencedType) {
27  }
28 
29  // constructors for fields and properties...
30  public ForeignKeyAttribute(Type referencedType, string referencedMember) {
31  ReferencedType = referencedType;
32  ReferencedMember = referencedMember;
33  }
34 
35  public ForeignKeyAttribute(string name, string referencedMember) {
36  ConstraintName = name;
37  ReferencedMember = referencedMember;
38  }
39 
40  public string ConstraintName { get; set; }
41 
42  public Type ReferencedType { get; private set; }
43 
44  public string ReferencedMember { get; private set; }
45 
46  public ForeignKeyAction OnUpdate { get; set; }
47 
48  public ForeignKeyAction OnDelete { get; set; }
49  }
50 }
ForeignKeyAttribute(string name, Type referencedType)
ForeignKeyAttribute(Type referencedType, ForeignKeyAction onUpdate, ForeignKeyAction onDelete)
ForeignKeyAttribute(Type referencedType, string referencedMember)
ForeignKeyAction
Enumerates the foreign key referential trigger actions.
ForeignKeyAttribute(string name, string referencedMember)
A user-defined TYPE that holds complex objects in a database column.
ForeignKeyAttribute(string name, Type referencedType, ForeignKeyAction onUpdate, ForeignKeyAction onDelete)