c# - Where clause with Join in lambda expression -
i using lambda expression clause join. here query
var activeimages = db.tbl_advertise .where(i => i.isvisible == true) .join(db.tbl_shopmast.where(i => i.isvisible == true && i.fk_userid == userid), => i.fk_shop_id, j => j.shopid, (i, j) => new { advertise = i, shop = j}) .tolist();
or can right query :
var activeimages = db.tbl_advertise .join(db.tbl_shopmast.where(i => i.isvisible == true && i.fk_userid == userid), => i.fk_shop_id, j => j.shopid, (i, j) => new { advertise = i, shop = j}) .tolist() .where(i=>i.advertise.isvisible == true);
which 1 works faster? although have noticed both giving same output, way correct?
with first query, where
clause executed on database server, while second query executed on client machine. because of that, first query:
- the database server more work;
- the client machine less work;
- less data transfered server client;
and second query it's opposite. it's hard faster. of time first query run faster , preferred, i've seen scenarios queries second 1 runs faster.
Comments
Post a Comment