I have the following:
public class Entity<TKey> : IEntity
{
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TKey Id { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual StateEnum State { get; set; }}
public class Party : Entity<int>
{
public virtual int TypeId { get; set; }
public virtual string MobileNo1 { get; set; }}
public class Person : Party
{
public virtual int PartyId { get; set; }
public virtual string Name { get; set; }}
I have in sql Party table contains the following columns [Id,TypedId,MobileNo1] and Person table contains the following columns:[PartyId,Name] and PartyId is foreign key for Id of Party .
How to make the mapping ? I have tried but i'm not reach to any thing.
Edit
suppose that TKey is integer and the PartyId is key of person and foreign key to party
I try to make map for person
HasKey(p => p.PartyId);
ToTable("Person");
and to party
HasKey(p => p.Id);
ToTable("Party");
and its not work, how I make mapping in this case ?
Edit 2:
I have the following
public class Entity<TKey> : IEntity
{
[System.Runtime.Serialization.DataMemberAttribute]
public virtual TKey Id { get; set; }
[System.Runtime.Serialization.DataMemberAttribute]
public virtual StateEnum State { get; set; }}
public class Person : Entity<int>
{
public virtual string FirstName{ get; set; }
public virtual string LastName{ get; set; }
}
public class Employee: Person
{
public virtual int PersonId { get; set; }
public virtual string CompanyName{ get; set; }
}
I have Person table contain [Id,FirstName,LastName] I have Employee table contain [PersonId,FirstName,LastName]
-- PersonId is foreign key to person table. -- employee is a person the relationship is one to one. --for future i can add Student entity , so Student is person
How I can make mapping ?
Employeeshould be both a person and have a link to a person? Why are you havingPersonIdonEmployee? - Jcl