entity framework - Joins vs associations in EF and Linq, performance diff? -
i removed 3 joins linq query against several entities , used associations between tables instead.
it seems queries take longer execute. made changes hoping performance improvements.
is consistent others have observed? there logical reason this? there rule of thumb strategy use?
linq query joins:
from n in db.names .where(n.id = "myid") **join d in db.institutiondemographics on n.id equals d.id bring together m in db.memberadhocids on n.id equals m.id bring together ba in db.nameaddresses on n.billingaddressnumber equals ba.addressnumber bring together sa in db.nameaddresses on n.shippingaddressnumber equals sa.addressnumber bring together ma in db.nameaddresses on n.mailingaddressnumber equals ma.addressnumber bring together mas in db.memberadhocservices on n.id equals mas.institutionid** bring together pn in db.primarycontactnames on n.id equals pn.id primename pn in primename.defaultifempty() bring together cd in currentduesresults on n.id equals cd.id duesjoin cd in duesjoin.defaultifempty() bring together bd in billingdateresults on n.id equals bd.id billingdate bd in billingdate.defaultifempty()
the ** marked section replaced associations in edmx file. relationships 1 to1 , constraints based on ids joins.
i have mention there no fk relationships on sql tables. (legacy stuff can not change)
** new info i've captured sql generated query using bring together -vs- associations , run ssms. performance identical. appears sql generated not issue else in how linq code working.
linq entity-framework
No comments:
Post a Comment