im trying to produce an if else statement inside entity query, i have the following code:
var asset = dbContext.Set<Asset>()
.Include(x => x.Item)
.Include(x => x.Item.ItemDetailSubCategory)
.Include(x => x.AssetCurrentStatus)
.Include(x => x.AssetCurrentStatus.AssetCondition)
.Include(x => x.Currency)
.Include(x => x.AssetCurrentStatus.AssetAccessories)
.Where(x => x.AssetCurrentStatus.Room.Floor.IsActive == true)
.Where(x => x.AssetCurrentStatus.Room.Floor.Building.IsActive == true)
.Where(x => x.AssetCurrentStatus.Room.IsActive == true)
.ToList();
now i expect something like :
var asset = dbContext.Set<Asset>()
.Include(x => x.Item)
.Include(x => x.Item.ItemDetailSubCategory)
.Include(x => x.AssetCurrentStatus)
.Include(x => x.AssetCurrentStatus.AssetCondition)
.Include(x => x.Currency)
.Include(x => x.AssetCurrentStatus.AssetAccessories)
if(x.AssetCurrentStatus.AssetLocation != null)
{
.Where(x => x.AssetCurrentStatus.Room.Floor.IsActive == true)
.Where(x => x.AssetCurrentStatus.Room.Floor.Building.IsActive == true)
.Where(x => x.AssetCurrentStatus.Room.IsActive == true)
}
else
{
.tolist()
}
is there any way to achieve this? thanks in advance
Aucun commentaire:
Enregistrer un commentaire