下面是我的查询,我根据某些条件使用 Linq 加入几个表
var Info = from tblcol1 in Table1
join tblcol2 in dc.Table2 on tblcol1.EmailID equals tblcol2.EmailID
join tblcol3 in dc.Table3 on tblcol1.EmailID equals tblcol3.EmailID
join tblcol4 in dc.Table4 on tblcol3.GroupID equals tblcol4.GroupID
join tblcol5 in dc.Table5 on tblcol4.RID equals tblcol5.RID
join tblcol6 in dc.Table6 on tblcol2.RID equals tblcol6.RID
join tblcol7 in dc.Table7 on tblcol1.EmailID equals tblcol7.EmailID
where tblcol1.UserId.Equals(gUserID)
select new Class1()
{
EmailID = tblcol1.EmailID.ToString(),
EmailName = tblcol1.Name.ToString(),
OpenCount = tblcol7.OpenCount,
ReadCount = tblcol7.ReadCount,
TotalCount = tblcol5.RID + tblcol6.RID,
UnsubscribeCount = tblcol6.IsUnsubscribed + tblcol5.IsUnsubscribed,
};
List = Info.ToList();
其中 RID 是 GUID(C#)/唯一标识符 (SQL),IsUnsubscribed 是 SQL 数据表中的位。
我需要在上面的查询中计算 TotalCount 和 UnsubscribedCount。
TotalCount = tblcol5.RID + tblcol6.RID,
UnsubscribeCount = tblcol6.IsUnsubscribed + tblcol5.IsUnsubscribed,
我该如何做到这一点?