I am a newbie to POCO.I have two tables like tb1 and tb2.Suppose we have a PK and FK relation between these tables.When it come to POCO CF how can we manage this relations?I have a done a sample by following a article.
public abstract class Person
{
public string Name { get; set; }
public int DepartmentId { get; set; }
public virtual Department Department { get; set; }
}
public class Collaborator : Person
{
public int CollaboratorId { get; set; }
public string ManagerCode { get; set; }
public virtual Manager Manager { get; set; }
}
Why they have used the abstract and virtual keywords? Can any one explain me the how can we manage the relations?
Why they have used the abstract and virtual keywords?
Hi,
As far as we know, an abastract class means tht it cannot create an instance of itself. Just like this, if you define an abstract class in POCO, this means this class cannot create into a real table. But if you have other tables that inherit from this, the
inherited table will contain the same properties that from the father model entity, which will reduce your writting codes.
Vitual: This is "One" part, because One Collaborator must belong to one Manager, but one Manager will have many collabortors.
hemaniwthu
Member
6 Points
31 Posts
How can we manage the Relation between two table in POCO Entity CF?
Nov 07, 2012 11:28 AM|LINK
I am a newbie to POCO.I have two tables like tb1 and tb2.Suppose we have a PK and FK relation between these tables.When it come to POCO CF how can we manage this relations?I have a done a sample by following a article.
public abstract class Person { public string Name { get; set; } public int DepartmentId { get; set; } public virtual Department Department { get; set; } } public class Collaborator : Person { public int CollaboratorId { get; set; } public string ManagerCode { get; set; } public virtual Manager Manager { get; set; } }Why they have used the abstract and virtual keywords? Can any one explain me the how can we manage the relations?
POCO RAZOR mvc
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How can we manage the Relation between two table in POCO Entity CF?
Nov 08, 2012 01:10 AM|LINK
Hi,
As far as we know, an abastract class means tht it cannot create an instance of itself. Just like this, if you define an abstract class in POCO, this means this class cannot create into a real table. But if you have other tables that inherit from this, the inherited table will contain the same properties that from the father model entity, which will reduce your writting codes.
Vitual: This is "One" part, because One Collaborator must belong to one Manager, but one Manager will have many collabortors.