Czy w Linq dostępna jest funkcja Unpivot (Not Pivot) na SQL? W jaki sposób?

Widziałem posty, które przyniosłyby Ci wyniki przestawne, ale nie rozpisane, Musisz wiedzieć, czy istnieje jakiś czysty sposób na osiągnięcie? Jeśli nie obejdzie się, obejdzie się również jakieś obejście?

Wykonaj to, aby zobaczyć wyniki niepodzielne w Management Studio

<code>CREATE TABLE [dbo].[Payment](
    [PaymentId] [int] NOT NULL,
    [EmployeeId] [int] NOT NULL,
    [RegularHours] [decimal](18, 0) NULL,
    [OvertimeHOurs] [decimal](18, 0) NULL
) ON [PRIMARY]

go

insert into payment values (1, 1, 40,  10)
insert into payment values (1, 2, 20,  0)

go

select * from payment 

select * from payment unpivot ([hours] for [paytype] in ([RegularHours], [OvertimeHOurs]))a
</code>

Dane wyjściowe dla pierwszej instrukcji Select

<code>PaymentId   EmployeeId  RegularHours                            OvertimeHOurs
----------- ----------- --------------------------------------- 
1           1           40                                      10
1           2           20                                      0

(2 row(s) affected)
</code>

Wynik dla drugiej instrukcji Select i tego właśnie szukam

<code>PaymentId   EmployeeId  hours                                   paytype
----------- ----------- ----------------------------------------------------- 
1           1           40                                      RegularHours
1           1           10                                      OvertimeHOurs
1           2           20                                      RegularHours
1           2           0                                       OvertimeHOurs

(4 row(s) affected)
</code>

questionAnswers(2)

yourAnswerToTheQuestion