I have issue with Include Method , scenario as given
Table Warehouse has columns
- Id--> unique identifier and PK
- warehouseNumber--nvarchar(50)
--some more columns
Table WarehouselnkedEcorders
- Id-->PK,unique Identifier
- warehouseUniqueId-->(FK,Unique Identifier), It has relationship with "Warehouse" table Id column
- Status
Warehouse Model has following Code
public class Warehouse
{
public Warehouse()
{
this.WarehouselnkedEcorders = new List<WarehouselnkedEcorder>();
}
//Some stuff
public virtual ICollection<WarehouselnkedEcorder> WarehouselnkedEcorders
{ get; set; }
}
WarehouselnkedEcOrdeMap has following Code
// Relationships
this.HasOptional(t => t.Warehouse)
.WithMany(t => t.WarehouselnkedEcorders)
.HasForeignKey(d => d.warehouseUniqueId);
Query
I need to retrive a list of warehouse entity with status=true. I tried the following way,but could not get result. How can I do this?
List<Warehouse> lstObjWarehouse = objWMSContext.Warehouses.Include("WarehouselnkedEcorders").Where(//o=>SomeCondition)
.Where(o => SomeCondition)
.Where(o => o.Deleted == false).ToList();
Here I need to compare value of status=true of each row of "WarehouselnkedEcorder" and it should return result.
Warehouse's relatedWarehouselnkedEcorders must have a trueStatusto include theWarehousein the result set?"WarehouselnkedEcorders"instead of"WarehouselnkedEcorder"?