I find it difficult to add any filter condition for the included elements in my LINQ query. My request is similar to
var item = _Context.Order.Include("Inner")
.Include("Inner.first")
.Include("Inner.second")
.Where(x => ( !(x.IsDeleted) && (x.IsActive) &&
(x.itemid == id))).FirstOrDefault();
In the code above, "Internal" is another list of items. Now I need to filter out the internal elements. I only need the inner element with the filter condition inner.isDeleted = true.
The request should return a class, for example
public class Order
{
public string Name { get; set; }
public List<InnerDetails> Inner{ get; set; }
public bool IsDeleted { get; set; }
}
and the InnerDetails class, for example
public class InnerDetails
{
public string Sample { get; set; }
public bool IsDeleted { get; set; }
public int firstId { get; set; }
public int secondID { get; set; }
public First first{ get; set; }
public Second second{ get; set; }
}
Can anyone suggest me a better approach for this because I'm new to LINQ and EF
source
share