I have the following model:
A workflowconfiguration has a Brand and also has a type.
A Workflowconfiguration has a collection of Approvers.
The Approvers entity has property Status and username.
In another part of the application, we have an entity called RequestBase
This entity has a string property called CurrentStatus.
I need to make a query with linq or EF Lambda expressions that returns me ALL requests which status matches the username on the approvers entity.
I know its a little bit complicated, or really much complicated, lol.
These are my entities(simplified)
public class RequestBase
{
public int RequestBaseId { get; set; }
public string CurrentStatus { get; set; }
}
public class WorkflowConfiguration
{
public int WorkflowConfigurationId { get; set; }
public WorkflowType WorkflowType { get; set; }
public Brand Brand { get; set; }
public virtual ICollection<Approver> Approvers { get; set; }
}
public class Approver
{
public Approver()
{
}
public Approver(string approverUserName)
{
Name = approverUserName;
}
public int Id { get; set; }
public string Name { get; set; }
public string StepName { get; set; } -----||||>>>>>> Must match status?
public int Order { get; set; }
}
and my query?
obviously it does not even compile
return _context.RequestBases.
.Where(a => a.CurrentStatus.Any(workflowconfiguration.Select(b=>b.Approvers.Select(c => c.StepName))));
1 Answer