I have a list of transactions data, which I group by the ItemID field which basically gives me the data how many times the transaction was made:
var _transactionsList = TransactionsData.GroupBy(x => x.ItemID).Select(pr => new TransactionsTabResults {
ItemID = pr.Key,
ItemPrice = pr.Select(x => x.ItemPrice).FirstOrDefault(), // the issue is here, prices are not matched for the exact product...
Title = pr.Select(x => x.Title).FirstOrDefault(),
TotalSoldItems = pr.Count(),
TotalRevenuePerItem = pr.Sum(y => y.ItemPrice),
AveragePrice = pr.Average(y => y.ItemPrice),
GalleryURL = pr.Select(x => x.GalleryURL).FirstOrDefault()
}).ToList();
The issue here is that after this LINQ the prices of the products are just not matched exactly as I'm expecting.
I've compared them to the data on eBay , and the prices are not matched exactly, rather they are shuffled around and none is matched with any...
How could I fix this ?
Edit: this isn't really a duplicate of the question as marked...
Rather, if I do group by the items by their prices, what am I going to be left with ? This isn't the solution ...
Edit: here is some sample data
ItemID: 282183606257 AmountPaid: 55.4
ItemID: 282183606257 AmountPaid: 43.5
ItemID: 282183606257 AmountPaid: 36.5
ItemID: 1218218553606234 AmountPaid: 15.4
ItemID: 1218218553606234 AmountPaid: 53.5
ItemID: 1218218553606234 AmountPaid: 66.5
ItemID: 282053079253 AmountPaid: 446.5
ItemID: 282053079253 AmountPaid: 246.5
ItemID: 282053079253 AmountPaid: 346.5
Basically these are transactions for the specific seller on eBay for the past 30 days... One item can be sold multiple times with different price (depending upon the moment of transaction);
I'm suspecting now that the reason why I'm getting wrong results because I'm grouping by the wrong value which is not actually unique, therefore I simply cannot assign the right value to each item ?