I have an EF 6 Task entity, which looks like this:
public class Task
{
public Guid TaskId {get; set;}
public TaskTypeEnum TaskType {get; set;}
public TaskStatusEnum TaskStatus {get; set;}
public virtual ICollection<Task> Dependencies {get; set;}
}
Tasks of a certain type can be dependent on all other tasks of a certain type to finish running before they run, and those dependencies should be defined in a table like this:
public class TaskTypeDependency
{
public TaskTypeEnum TaskType {get; set;}
public TaskTypeEnum DependsOnTaskType {get; set;}
}
Example of what I want- Task A has Type 1, Task B and C have Type 2. I have a TaskTypeDependency of
TaskType | DependsOnTaskType
----------------------------
1 | 2
At runtime, I want to get all the tasks that task is dependent on, which for Task A would be Task B and Task C, to check if the dependent tasks have completed. Is there a way to set this relationship up in Code-First, maybe with Fluent API? Or am I stuck using LINQ to sort this all out without a virtual property?
Dependencies
collection.