LINQ to SQL Join issues

前端 未结 3 552
迷失自我
迷失自我 2021-01-05 09:06

I\'m trying to use the following LINQ to SQL in my code:

  (from s in dc.Accounts 
  join purchases in dc.Transactions on s.AccID equals purchases.Account in         


        
3条回答
  •  迷失自我
    2021-01-05 09:56

    From the MSDN docs:

    Type inference on composite keys depends on the names of the properties in the keys, and the order in which they occur. If the properties in the source sequences do not have the same names, you must assign new names in the keys. For example, if the Orders table and OrderDetails table each used different names for their columns, you could create composite keys by assigning identical names in the anonymous types:

    join...on new {Name = o.CustomerName, ID = o.CustID} equals 
       new {Name = d.CustName, ID = d.CustID }
    

    http://msdn.microsoft.com/en-us/library/bb907099.aspx

提交回复
热议问题