c# - Explicitly load related entities in many-to-many relationship with Entity Framework over WCF -


i'm using ef 4.1 self-tracking entities in layered application uses wcf hand entities , forth client server.

a portion of database contains 3 tables:

customer contact customercontacts 

customercontacts contains 2 primary keys of customer , contact, edm represents navigation properties - customer.contacts , contacts.customers. customercontacts table not represented otherwise in model, meaning there no customercontacts entity, understand , expect feature of edm designer when representing many-to-many relationships of form.

the situation have list of customers bound combobox , wish load related contacts of customer @ point when selected in combobox. put way, wish explicilty load customer.contacts when customer selected in combobox. can't use customer.id in where fetch list of contacts, since there no join entity in model relates them.

currently, loading copy of customer, using include("contacts") contacts , setting via selectedcustomer.contacts = temporarycustomer.contacts;

does know of method doesn't require fetch redundant, temporary copy of customer?

you know id of selected customer can pass wcf parameter , query contacts related customer:

var customercontacts = context.contacts .where(c => c.customers.any(cu => cu.id == passedid)); 

anyway should think replacing wcf stes wcf data services more suitable scenarios , support many features (including loading of navigation property) out-of-the-box.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -