I have a service that brings back a List result with IJoin interfaces. In the service I get the Query and append where clauses to the query. This is working fine. I have a reference property on the Item class that brings back inventory items that share the Item’s ItemKey. I was wondering if there was a method to only return certain inventory items that have quantities?
This part works like I expect. I am getting any item that has any quantities available.
[Route("/MAS/Item/{CompanyID}")]
[Route("/MAS/Item/{CompanyID}/{ItemID}")]
[Route("/MAS/Item/{CompanyID}/{ItemID}/{Status}")]
[NamedConnection("MAS")]
public class MASItemQuery : QueryDb<MASItem>, IJoin<MASItem, ItemUnitOfMeasure>, IJoin<MASItem, BinInventory>, IJoin<BinInventory, WarehouseBin>
{
[QueryDbField(Field = "ItemID", Template = "{Field} like {Value}", ValueFormat = "%{0}%" )]
public string ItemID { get; set; }
public string CompanyID { get; set; }
public int? Status { get; set; }
}
public object Any(MASItemQuery query)
{
var q = AutoQuery.CreateQuery(query, base.Request);
q.Where<BinInventory>(bi => bi.QtyOnHand > 0 || bi.PendQtyDecrease > 0 || bi.PendQtyIncrease > 0).Where<WarehouseBin>(b => b.Status == 1);
return AutoQuery.Execute(query, q);
}
This is an abbreviated example of the Item class.
public class MASItem
{
[Display(AutoGenerateField = false, AutoGenerateFilter = true, ShortName = "ItemKey")]
public int ItemKey { get; set; }
[Reference]
public List<BinInventory> BinInventories { get; set; } = new List<BinInventory>();
}
This is an abbreviated example of the BinInventory class.
public class BinInventory
{
[Display(AutoGenerateField = true, AutoGenerateFilter = true, ShortName = "WhseBinKey")]
[References(typeof(WarehouseBin))]
public int WhseBinKey { get; set; }
[Display(AutoGenerateField = true, AutoGenerateFilter = true, ShortName = "ItemKey")]
[References(typeof(MASItem))]
public int ItemKey { get; set; }
[Display(AutoGenerateField = true, AutoGenerateFilter = true, ShortName = "PendQtyDecrease")]
public decimal PendQtyDecrease { get; set; }
[Display(AutoGenerateField = true, AutoGenerateFilter = true, ShortName = "PendQtyIncrease")]
public decimal PendQtyIncrease { get; set; }
[Display(AutoGenerateField = true, AutoGenerateFilter = true, ShortName = "QtyOnHand")]
public decimal QtyOnHand { get; set; }
}
What I am trying to do is return a BinInventory item if any of the quantities have values > 0.
Is there a way to accomplish this?