c# - Best way to access data in related tables -
i have 2 tables conceptually related original coder did not create fk relationship between tables.
table1:
table [name]( id [varchar](10) not null (this pk), mail_address_num [int] not null, bill_address_num [int] not null, shipping_address_num [int] not null )
table2:
table [address]( id [varchar](10) not null, address_num [int] not null (this pk), purpose [varchar](20) not null )
if had alternative set fks on mailingaddress addressnumber, billingaddress addressnumber, , shippingaddress addressnum. not option.
currently in linq like:
from n in names.where(predicate) bring together ba in db.addresses on n.billingaddressnumber equals ba.addressnumber bring together sa in db.addresses on n.shippingaddressnumber equals sa.addressnumber bring together ma in db.addresses on n.mailingaddressnumber equals ma.addressnumber
if understand ef , linq correctly should able create association in/on edmx design surface , simplify query. correct?
if steps need taken add together right associations edmx files? have found references seem involve fair amount of manipulating underlying xml files. necessary? these tables strictly read-only. using vs2012 , ef5.
c# linq entity-framework join linq-to-entities
No comments:
Post a Comment