English 中文(简体)
Linq2 Sql 生成的q 是否使用单一()手段?
原标题:Does Linq2Sql generated sql contains Top or not when Single() is used?

当我执行“Linq2Sql”问询时,就如

db.Items.Single(it => it.Id == 1)

有些人坚持说,产生的锡克尔就像这样的。

select TOP (2) [t0].Id, [t0].Name
from [dbo].[SomeTable] as [t0]
where [t0].Id = @p0

but what I get from Sql Server Profiler (and Linqpad s sql window, and VS IntelliTrace window) shows that the sql does not contains any TOP, just plain

select [t0].Id, [t0].Name
from [dbo].[SomeTable] as [t0]
where [t0].Id = @p0

林克版本是否是问题? I m 采用4.0网框架,并参照4版系统。 数据。

最佳回答

第一个问题由实体框架提出,该框架使用TOP(2),但第2个问题是由Linq-to-Sql提出的,Linq-to-Sql使用TOP(2),而如果结果包含不止一个记录,则按阅读逻辑进行核对(在这种情况下作简短阅读)。

问题回答

暂无回答




相关问题
LINQ to SQL as databinding source for WPF Treeview

I wonder if someone could provide a simple example of the following. (preferably in VB.Net): I have an SQL database with related tables and I am successfully using LINQ to SQL in other areas of my ...

Linq to SQL insert/select foreign/primary records

I have table A and Table B. Table B contains two columns, Name and ID. Table A contains several columns and a foreign key column pointing to B.ID called B_ID On the client side, I have all the data I ...

LINQ to SQL Dynamic Sort question

How do I code the Select clause in my LINQ satament to select column aliases so I can sort on them basically I want to accomplish this SQL statement in LINQ: select type_id as id, ...

Using a schema other than dbo in LinqToSql Designer

Is there a way to specify in a data connection or the LinqToSql Designer a schema? Whenever I go to setup a data connection for LinqToSql there doesn t seem to be anyway to specify a schema and I ...

热门标签