Hi All,
I am using forward mapping.I have to declare a foreign key in one of my class.How can i do this and also how can i set default value for a filed?
Thanks.
2 Answers, 1 is accepted
0
Accepted
Damyan Bogoev
Telerik team
answered on 02 Dec 2009, 02:24 PM
Hi Ratndeep,
You could use the following approach in order to declare a foreign key in one of your classes during the forward mapping:
1. Inside the class declare a reference to the other class as well as the foreign key:
public class ClassOne
{
...
private int id;
public int Id
{
get { return id; }
set { id = value; }
}
...
}
public class ClassTwo
{
...
private int id;
public int Id
{
get { return id; }
set { id = value; }
}
private ClassOne classOne;
public ClassOne ClassOne
{
get { return classOne; }
set { classOne = value; }
}
private int classOneId;
public int ClassOneId
{
get { return classOneId; }
set { classOneId = value; }
}
...
}
2. When you finish with the settings inside the Forward Mapping wizard open the App.config file
3. You should map the classOne and the classOneId fields to one and the same column inside the App.config: