What is the syntax for an inner join in LINQ to SQL?

后端 未结 19 1633
感情败类
感情败类 2020-11-22 04:25

I\'m writing a LINQ to SQL statement, and I\'m after the standard syntax for a normal inner join with an ON clause in C#.

How do you represent the follo

相关标签:
19条回答
  • 2020-11-22 05:18

    You create a foreign key, and LINQ-to-SQL creates navigation properties for you. Each Dealer will then have a collection of DealerContacts which you can select, filter, and manipulate.

    from contact in dealer.DealerContacts select contact
    

    or

    context.Dealers.Select(d => d.DealerContacts)
    

    If you're not using navigation properties, you're missing out one of the main benefits on LINQ-to-SQL - the part that maps the object graph.

    0 讨论(0)
提交回复
热议问题