Is it possible to create a ForeignKeyConstraint with a static valu

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to create two ForeignKeyConstraints like this..

ParentTableA - ForeignKeyConstraint on ParentTableA.PrimaryKey =
ChildTableA.ForeignKey1 and ChildTableA.UseTableA = True

ParentTableB - ForeignKeyConstraint on ParentTableB.PrimaryKey =
ChildTableA.ForeignKey1 and ChildTableA.UseTableA = False

Is this possible? I have not found any way to create a ForeignKeyConstraint
on a static value. I want to be able to do this so that when I change the
PrimaryKey of a parent table, it will correctly cascade and update the child
rows. I would also like to be able to create a DataRelation this same way.
 
You could create 1 table, with 1 column and 1 row - and make a regular
constraint against it??

Harry Keck said:
I would like to create two ForeignKeyConstraints like this..

ParentTableA - ForeignKeyConstraint on ParentTableA.PrimaryKey =
ChildTableA.ForeignKey1 and ChildTableA.UseTableA = True

ParentTableB - ForeignKeyConstraint on ParentTableB.PrimaryKey =
ChildTableA.ForeignKey1 and ChildTableA.UseTableA = False

Is this possible? I have not found any way to create a ForeignKeyConstraint
on a static value. I want to be able to do this so that when I change the
PrimaryKey of a parent table, it will correctly cascade and update the child
rows. I would also like to be able to create a DataRelation this same
way.
 
I'm not sure that I follow. Doesn't a constraint only allow one parent and
child table, no matter how many columns are indicated? I could not create a
constraint against a third table, while still being on the first two.
 
I am thinking about creating a new type of contraint by inheriting from
ForeignKeyConstraint or System.Data.Constraint. Has anyone done this before?
Is there any documentation on things to consider when creating new
constraints, if it is even possilbe?
 
Back
Top