Reputation: 151
I am trying to display values of three columns, but I am able to get values of only two columns ID
and TOTAL
. It returns an empty column for Medical_Store
.
Below is my code
var newDt = (from p in dt_1.AsEnumerable()
group p by p["invoice_id"]
into r
select new
{
ID = r.Key,
Total = r.Sum((s) => decimal.Parse(s["total_price"].ToString())),
MEDICAL_STORE = r.Select((s) => (s["medical_store_name"].ToString()))
})
.ToList();
dataGrid2.ItemsSource = newDt;
Upvotes: 0
Views: 233
Reputation: 23923
The issue is that your query is not populating MEDICAL_STORE
with a single medical store, but a collection / enumerable of them.
I suspect instead of:
MEDICAL_STORE = r.Select((s) => (s["medical_store_name"].ToString()))
that you wish to use:
MEDICAL_STORE = r.Max((s) => (s["medical_store_name"].ToString()))
to get a single value instead.
Upvotes: 1