How do I create a Linq query with a many to many relationship model
-
Tuesday, September 13, 2011 2:55 AM
Hi
I have a many to many relationship with the linking table that holds specific information to the many to many relationship as such
DB a {a_ID, ...}
DB b {b_ID,...}
DB c {c_ID,a_ID,b_ID, cdate,....}
I want to create a Linq statment(s) that takes each unique a<=>b relationship and finds the a<=>b with the newest date. I figure Max will get the latest date but I can't figure out the how LINQ can work the grouping.
I also hope what I am saying makes sense
Thanks
Tim
All Replies
-
Tuesday, September 13, 2011 9:12 AM
easiest is always to begin with the table that holds the foreign key.
E.g
var query = from row in context.C select row; return query.Distinct(); -
Wednesday, September 14, 2011 6:16 AM
I dont very understand your means. what's the meaning of newest date in your question?
Thanks,
Werewolf,
Just a newbie for everything. -
Tuesday, September 20, 2011 2:07 AMModerator
Any update? Would you mind letting us know how it goes now?
Please feel free to let us know if you need furhter support.
Thanks,
Larcolais Gong[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

-
Tuesday, September 20, 2011 11:38 PMI couldn't get it to work so I restructured my database tables splitting off the inventory history aspect solving my problem

