i am using linq expression in c#, but it trigger error of specified case is not valid, can any body show me the better way of my code, thanks
What I have tried:
var newDt = dt.AsEnumerable()
.GroupBy(r => new { name = r["name"], email = r["email"], phoneNo=
r["phone_no"], checkIn = r["check_in"], checkOut =
r["check_out"],noDate = r["no_date"], clientValidationCode =
r["client_validation_code"],clientBookingType =
r["client_booking_type"],clientPaymentGateway =
r["client_payment_gateway"], clientCreatedAt =
r["client_created_at"],status = r["status"]
})
.Select(g => new
{
Name = g.Key.name,
Email= g.Key.email,
PhoneNo= g.Key.phoneNo,
CheckIn= g.Key.checkIn,
CheckOut= g.Key.checkOut,
NoDate= g.Key.noDate,
ClientValidationCode= g.Key.clientValidationCode,
ClientBookingType= g.Key.clientBookingType,
ClientPaymenetGateway= g.Key.clientPaymentGateway,
ClientCreatedAt= g.Key.clientCreatedAt,
Status =g.Key.status,
type_no = string.Join(",", g.Select(z => z.Field<string>
("room_no"))),
clientBookingId = g.Min(r=> r.Field<int>("client_booking_id")),
extraDiscount = g.Sum(r => r.Field<decimal>("extra_discount")),
netPrice = g.Sum(r => r.Field<decimal>("netPrice")),
commission = g.Sum(r => r.Field<decimal>("commission")),
vatOrg = g.Sum(r => r.Field<decimal>("vat_org")),
vatGetrest = g.Sum(r => r.Field<decimal>("vat_getrest")),
payed = g.Sum(r => r.Field<decimal>("payed")),
unPayed = g.Sum(r => r.Field<decimal>("un_payed")),
});