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
我会怎么做呢?