I have an inherited class configuration that is using TPH and has created a single table with a discriminator column, and some of my own nullable fields
public abstract class ActionBase
{
/// ctor1
public ActionBase(long issueId)
{
IssueId = issueId;
Url = $"https://mypath.com/{issueId}";
}
/// ctor2
public ActionBase(long issueId, long locationId)
{
IssueId = issueId;
LocationId = locationId;
Url = $"https://mypath.com/{issueId}/{locationId}";
}
public long IssueId {get;set;}
public long? LocationId {get;set;}
public Url { get; }
}
public class BlogAction: ActionBase
{
/// ctor1
public ReadBlogAction(long issueId): base(issueId) {}
}
public class LocationAction: ActionBase
{
/// ctor1
public ReadBlogAction(long issueId, long locationId): base(issueId, locationId) {}
}
public class BlogLocationAction: ActionBase
{
/// ctor1
public ReadBlogAction(long issueId): base(issueId) {}
/// ctor2
public ReadBlogAction(long issueId, long locationId): base(issueId, locationId) {}
}
When I create instances of the BlogLocationAction class the first constructor is always run. How can I require the 2nd constructor to be used if LocationId is not null?