I have following classes in my model:
public class Party
{
public int Id {get; set;}
}
[Table("Person")]
public class Person:Party
{
public string FirstName {get; set;}
public string LastName {get; set;}
}
[Table("Organization")]
public class Organization:Party
{
public string Name {get; set;}
}
How can I query over Parties
and return result as following PartyViewModel
, using linq-to-entities Fluent API
?
public PartyViewModel
{
public int Id {get;set;}
public string FirstName {get;set;}
public string LastName {get;set;}
public string Name {get;set;}
}
e.g if I have following records:
Person Table
------------------------
Id FirstName LastName
0 John Smith
Organization Table
------------------------
Id Name
1 Microsoft
I want to, the query returns:
PartyViewModel
---------------------------------
Id FirstName LastName Name
0 John Smith null
1 null null Microsoft