0
我附加了一个简单的LINQ查询。 我想知道是否有更好和有效的方法来拉动这三个字段(Field1,Field2,Field3),如下面的LINQ查询中所述。优化Linq查询
from currentCons in ActiveConnections
join accounts in Accounts on currentCons.New_AccountId equals accounts.AccountId
let Field1 =(from holder in MapHolders
join entity in Entities on stringmap.ObjectTypeCode equals entity.ObjectTypeCode
where entity.Name == "New_Connection"
where holder.AttributeName == "New_Data"
where holder.AttributeValue == currentCons.New_DATA_Val
select holder.Value)
let Field2=(from holder in MapHolders
join entity in Entities on stringmap.ObjectTypeCode equals entity.ObjectTypeCode
where entity.Name == "New_Connection"
where holder.AttributeName == "New_Type"
where holder.AttributeValue == currentCons.New_Type
select holder.Value)
let Field3=(from holder in MapHolders
join entity in Entities on stringmap.ObjectTypeCode equals entity.ObjectTypeCode
where entity.Name == "New_Connection"
where holder.AttributeName == "New_EntryPoint"
where holder.AttributeValue == currentCons.New_EntryPoint
select holder.Value)
where currentCons.ModifiedOn >= Convert.ToDateTime("1/1/2011")
where currentCons.ModifiedOn <= Convert.ToDateTime("5/5/2012")
select new
{
conId = currentCons.ConnectionId,
ConName = currentCons.name,
TypeId = currentCons.Type,
AccountId = currentCons.AccountId,
OId = currentCons.OwnerId,
BandwidthId = currentCons.Bandwidth,
EntryPointId = currentCons.EntryPoint,
Cap = Field1 ,
Dir=Field2,
EP=Field3,
ModifiedOn = currentCons.ModifiedOn
}
我知道另一种方式是直接放入选择块。什么是有效的方法来做到这一点?
任何指针表示赞赏。
谢谢。
什么LINQ提供您正在使用可空用下面的? LINQ to SQL? LINQ to Entities?还有别的吗? – svick
我在这里使用LINQ To SQL。 – Tabish