[英]Filter a list Using Linq C#
public class Orgs
{
public int Id { get; set; }
public DateTime OrgCreationTime { get; set; }
public string AppUserId { get; set; }
public virtual ICollection<OrgPersonRelationshipDomain> ManyOrgPersonRelationship { get; set; }
}
public class OrgPersonRelationshipDomain
{
//public int ID { get; set; }
public int OrgId { get; set; }
public virtual OrgDomain Org { get; set; }
public bool IsDeleted { get; set; }
}
var orgs = await _context.Org.Where(x => x.Id == request.Id).ToListAsync(); var orgs = await _context.Org.Where(x => x.Id == request.Id).ToListAsync();
How to filter list where "orgs" should give result with IsDeleted!= true
?如何使用IsDeleted!= true
过滤“orgs”应该给出结果的列表? Result I am getting is only ManyOrgPersonRelationship item but I want Orgs properties included in it.我得到的结果只是 ManyOrgPersonRelationship 项目,但我希望其中包含 Orgs 属性。 ` `
Try this:尝试这个:
var orgs = _context.Org.Where(x => x.AppUserId == userId && x.ManyOrgPersonRelationship.Any(x => x.IsDeleted != false)).ToList();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.