使用 Linq 对“键/值表”的实体执行以下查询时,我得到[System.NotSupportedException] "Specified method not supported"
:
有人可以提示我做错了什么吗?
var Pivot = context.goe_postmeta.GroupBy(pm => pm.post_id).Select(
g => new PivotTemp
{
ID = g.Key,
FirstName = g.FirstOrDefault(p => p.meta_key == "_billing_first_name").meta_value,
LastName = g.FirstOrDefault(p => p.meta_key == "_billing_last_name").meta_value,
Address = g.FirstOrDefault(p => p.meta_key == "_billing_address_1").meta_value,
PostCode = g.FirstOrDefault(p => p.meta_key == "_billing_postcode").meta_value,
Phone = g.FirstOrDefault(p => p.meta_key == "_billing_phone").meta_value,
OrderTotal = g.FirstOrDefault(p => p.meta_key == "_order_total").meta_value,
PickupLocation = g.FirstOrDefault(p => p.meta_key == "_pickup_location").meta_value,
PickupTime = g.FirstOrDefault(p => p.meta_key == "_pickup_time").meta_value,
OrderItems = g.FirstOrDefault(p => p.meta_key == "_order_items").meta_value
}).ToList();