Hello,
I am using EF 6. I am querying a table as follows:
And getting a response from web API as follows:
I wonder if there is a way to concat 2 lists? I tried this but it says the type arguments for method IEnum concat can not be inferred from usage. Try specifying the type arguments explicitly.
I am using EF 6. I am querying a table as follows:
C#:
//Query GameBank database
var gameBankProductListResult = await _unitOfWork.GameBankRepository.GetGameBankProducts(
x => x.used == 0,
g => new {g.productCode, g.productDescription, g.unitPrice}, gcs => new
{
ProductID = gcs.Key.productCode,
ProductName = gcs.Key.productDescription,
Price = gcs.Key.unitPrice,
StockQuantity = gcs.Sum(g => g.quantity),
IsStockAvailable = gcs.Sum(g => g.quantity) > 0
});
And getting a response from web API as follows:
C#:
response = await Utilities.CallRazer(products, "Product/");
var htmlResponse = await response.Content.ReadAsStringAsync();
var model = JsonConvert.DeserializeObject<ProductResponseDto>(htmlResponse);
var productsListRazer = model.Products.Select(gcs =>
new
{
gcs.ProductID,
gcs.ProductName,
gcs.Price,
gcs.StockQuantity,
gcs.IsStockAvailable
})
.ToList();
I wonder if there is a way to concat 2 lists? I tried this but it says the type arguments for method IEnum concat can not be inferred from usage. Try specifying the type arguments explicitly.
C#:
var merged = productsListRazer.Concat(productsListRazer)
.GroupBy(g => new {g.ProductID, g.ProductName, g.Price, g.IsStockAvailable})
.Select(gcs => new
{
gcs.First().ProductID,
gcs.Key.ProductName,
gcs.Key.Price,
StockQuantity = gcs.Sum(g => g.StockQuantity),
gcs.Key.IsStockAvailable
})
.ToList();