此代码有效,但速度非常慢。我正在使用实体框架 5.0。那么,仅使用 Linq 或 Lambda,我如何结合这两段代码来返回List<Entity> e
?
CMSEntities c = new CMSEntities();
var p = c.Entities.Where(
x => x.Address != null
&& x.Address.AddressType != null
&& x.Address.AddressType.AddressTypeID == 1
&& x.Tags.FirstOrDefault() != null)
.ToList();
List<Entity> e = new List<Entity>();
foreach (var a in p)
{
var d = a.Tags.Where(y => y.Feature.FeatureID == 39).FirstOrDefault();
if (d != null)
{
e.Add(a);
}
}