Сначала я задавал вопрос, когда получал ошибку с аналогичным запросом, и нашел помощь в ее исправлении. Теперь у меня есть вопрос / потребность в небольшой помощи, чтобы понять, как сформулировать правильную группу для возврата, это будетбыть для веб-API и нужно сгруппировать вывод определенным образом, и я не могу получить там.
Класс -
public class GoodInWarehouseBM
{
/// <summary>
/// Pallet Number
/// </summary>
public string pallet_identifier { get; set; }
public List<ShipmentItems> shipment_items { get; set; }
public class ShipmentItems
{
/// <summary>
/// SKU Code
/// </summary>
public string sku { get; set; }
/// <summary>
/// Products on Pallet
/// </summary>
public decimal stock_qty { get; set; }
/// <summary>
/// Description of Item
/// </summary>
public string description { get; set; }
}
}
Метод -
public IQueryable<IGrouping<string, GoodInWarehouseBM>> GetWarehouseToStoreList(string storeId)
{
var entity = (from consighdrs in mi9TestEntities.consighdrs
join consigdests in mi9TestEntities.consigdests on consighdrs.consignment equals consigdests.consignment
join consigliness in mi9TestEntities.consiglines on consigdests.condestint equals consigliness
.condestint
join productcodess in mi9TestEntities.productcodes on consigliness.varint equals productcodess.varint
join products in mi9TestEntities.products on productcodess.prodint equals products.prodint
where consigdests.destination == storeId && consighdrs.status == "T"
select new GoodInWarehouseBM()
{
pallet_identifier = consigdests.consignment,
shipment_items = new List<GoodInWarehouseBM.ShipmentItems>
{new GoodInWarehouseBM.ShipmentItems
{
sku = productcodess.variantcode,
stock_qty = consigliness.issueqty,
description = products.proddesc
}}
}).GroupBy(x => x.pallet_identifier);
return entity;
}
ouput -
[
[
{
"pallet_identifier": "FS300057058",
"shipment_items": [
{
"sku": "051657",
"stock_qty": 1,
"description": "BELT 1.25\" 5028"
}
]
},
{
"pallet_identifier": "FS300057058",
"shipment_items": [
{
"sku": "10121781",
"stock_qty": 1,
"description": "SLAZ CREW SWEAT"
}
]
},
требуемый вывод -
[
{
"pallet_identifier": "FS300057058",
"shipment_items": [
{
"sku": "051657",
"stock_qty": 1,
"description": "BELT 1.25\" 5028"
},
{
"sku": "10121781",
"stock_qty": 1,
"description": "SLAZ CREW SWEAT"
}
]
}
]
Я, кажется, оборачиваюсь здесь тем, как на самом деле получить этот результат, любая помощь и указатели будут с благодарностью приняты.