0

我很陌生Linq,我正在尝试某种过滤。

 var customers = from c in Customers select c;


if (regDate.HasValue)
    customers = from c customers
            join p in CustomerProducts on c.Id equals p.CusId
            where dss.rate == rate
            select c;

if (productName.HasValue)
    customers = from c customers
                join cp in CustomerProducts on c.Id equals cp.CusId
                join p in Products on cp.pId equals p.Id
                where p.Name == pName
                select c;

.....
.....

regDate 和 productName都具有值的情况下,连接发生两次

join p in CustomerProducts on c.Id equals p.CusId

由于我是新手,因此我不知道这种情况是否会产生不良影响。请指教。我。

4

0 回答 0