c# - How to model a non-standard relationship in EDMX? -


i'm trying model non-standard relationship using .net entity framework 4 consumption on restful wcf data service.

consider following simplified data structure metadata stored in single table, may associated different entities stored in different tables (identified type column)

metadata table -------------- id      fk_id   type        value --      ----    -----       ----- 1       100     product     foo 2       101     product     foo 3       101     service     bar 4       102     service     bar  product table ------------- id      name --      ---- 100     101     b 102     c 103     d  service table ------------- id      name --      ---- 100     w 101     x    102     y 103     z 

the problem facing want create property

product.list<metadata>  

for product object , service object. since not associated single fk single table don't know how can model relationship in edmx file.

my end goal able call method on wcf data service, , return json response has product serialized list of metadata included.

one way create either computed column or view additional column each of tables has metadata , populate additional column name of table.

create view product_view     select id, name, "product" type product 

or

create table product(   id int,   name varchar(20),   type "product" ) 

then can have fk relationship between product_view/product , metadata on fields fk_id , type. these 2 fields mapped complex type , relationship between metadata table , product_view can formed in ef.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -