var data11 = (from p in db.FeePlan.Where(d => d.AcademicYearID == dts.AcademicYearID && d.Active == true && d.IsEffectiveDates == false)
from fb in db.FeePlansToBranches.Where(x => x.FeePlanID == p.FeePlanID && x.BranchID == BranchID)
from b in db.Branches.Where(b => b.BranchID == fb.BranchID)
from fp in db.AssignFeeplanToClasses.Where(a => a.BranchID == BranchID && a.ClassID == ClassID && a.FeePlanID == p.FeePlanID)
from cl in db.Classes.Where(c => c.ClassID == fp.ClassID)
select new
{
p.FeePlanName,
p.FeePlanID,
b.BranchName,
cl.ClassName,
fp.AssignFeeplanToClassID,
fp.CreatedDate
}).Distinct().ToList();
var data2 = (from p in db.FeePlan.Where(d => d.AcademicYearID == dts.AcademicYearID && d.Active == true &&d.IsEffectiveDates == true)
from fb in db.FeePlansToBranches.Where(x => x.FeePlanID == p.FeePlanID && x.BranchID == BranchID)
from b in db.Branches.Where(b => b.BranchID == fb.BranchID)
from fp in db.AssignFeeplanToClasses.Where(a => a.BranchID == BranchID && a.ClassID == ClassID && a.FeePlanID == p.FeePlanID)
from cl in db.Classes.Where(c => c.ClassID == fp.ClassID)
where (DateTime.Now> p.StartDate && DateTime.Now < p.EndDate)
select new
{
p.FeePlanName,
p.FeePlanID,
cl.ClassName,
b.BranchName,
fp.AssignFeeplanToClassID,
fp.CreatedDate
}).Distinct().ToList();
js.Data = data11.Union(data2);
我是新來的LINQ;請幫助我如何在LINQ查詢中使用union all爲兩個變量存儲結果。如何寫工會都在LINQ兩個LINQ導致
在我使用兩個LINQ查詢,得到的結果上面的代碼,但我想工會存儲在其他變量的兩個結果。請幫幫我。
您可以使用[的AddRange(https://msdn.microsoft.com/en-us/library/z883w3dc(V = vs.110)的.aspx) – bansi