14
我有以下表格:如何在LINQ-to-SQL中編寫這個交叉應用查詢?
create table TableA (
Id int primary key identity,
Key int not null
)
create table TableB (
Id int primary key identity,
TableA_Id int not null foreign key references TableA(Id),
Value varchar(80) not null
)
我想編寫的LINQ到SQL使用lambda符號下面的查詢:
select TableA.Key, b.Value
from TableA
cross apply (
select top 10 TableB.Value
from TableB
where TableA.Id = TableB.TableA_Id
order by TableB.Value
) b
where TableA.Key between 0 and 999
我會怎麼做呢?