我想知道即使对于小型数据库,这个 linq 查询也需要几个小时。有一个带有子查询的旧版本,但它会抛出异常。
var a = (
from item1 in fullMappingData
from item2 in dc.EntityMasters
from item3 in dc.Entities
from item4 in dc.Contributors
where (
item1.Name
.Replace(" ", "")
.Replace(",", "")
.Trim()
== item2.CBEntityName
.Replace(" ", "")
.Replace(",", "")
.Trim()
&&
item1.ContributedName
.Replace(" ", "")
.Replace(",", "")
.Trim()
== item3.EntityName
.Replace(" ", "")
.Replace(",", "")
.Trim()
&&
item1.ContributorName
.Replace(" ", "")
.Replace(",", "")
.Trim()
== item4.ContributorName
.Replace(" ", "")
.Replace(",", "")
.Trim()
)
select new Mapping
{
ContributedID =item3.ContributedID, // (from x in dc.Entities
//where x.EntityName.Replace(" ", "").Replace(".", "").Replace(",", "").Trim() == item1.ContributedName.Replace(" ", "").Replace(",", "").Trim()
//select x.ContributedID).First(),
ContributorID = item4.ContributorID,//(from x in dc.Contributors
//where x.ContributorName.Replace(" ", "").Replace(".", "").Replace(",", "").Trim() == contributor.Replace(" ", "").Replace(",", "").Trim()
//select x.ContributorID).First(),
NameID = item2.NameID //(from x in dc.EntityMasters
// where x.EntityName.Replace(" ", "").Replace(".", "").Replace(",", "").Trim() == item1.Name.Replace(" ", "").Replace(",", "").Trim()
//select x.NameID).First()
}
);
谢谢!