【发布时间】:2017-05-12 10:03:08
【问题描述】:
我有一个如下的 linq:
var finalist = (from b in GeneralAction.EM().Vwmembersummarydetails
where selectedPersonId.Contains(b.Id)
select new GeneralCommonFunctions.MemberDetailSumary
{
Index = 0,
ProjectText = string.Join(", ", (from d in GeneralAction.EM().Member_has_properties
join e in GeneralAction.EM().Properties on d.Property_id equals e.Id
where d.IsDeleted == 0 && d.Member_id == b.Id && e.ProjectType_id == Convert.ToInt32(projectTypeId)
select e.Project.Description).Distinct().ToArray()),
PropertyText = string.Join(", ", (from f in GeneralAction.EM().Member_has_properties
join g in GeneralAction.EM().Properties on f.Property_id equals g.Id
where f.IsDeleted == 0 && f.Member_id == b.Id && g.ProjectType_id == Convert.ToInt32(projectTypeId)
select g.LotNum).ToArray()),
PurchasePrice = GeneralCommonFunctions.GetTotalPurchasePriceByProjectType(b.Id, projectTypeId),
Name = b.Name,
Email = b.Email,
}).AsQueryable();
我想问一下,如何忽略这两个条件:
e.ProjectType_id == Convert.ToInt32(projectTypeId)
g.ProjectType_id == Convert.ToInt32(projectTypeId)
当 projectTypeId 为 null 或 0 时。
【问题讨论】:
-
你熟悉三元运算符吗?