如何使用内连接将 SQL 查询转换为 Lambda 表达式

How Convert SQL Query to Lambda Expression with Inner Join

 SELECT computer.*,
       computerdetail.manufacture,
       computerdetail.model,
       computerdetail.noofshares,
       computerdetail.phymem,
       computerdetail.processor,
       computerdetail.numloproc,
       computerdetail.numphproc
FROM   computer
       INNER JOIN computerdetail   ON computer.id = computerdetail.computerid  

您没有提供任何您想要的详细信息。因此,假设您只想使用 Join 将查询转换为 lambada expression,转换可以如下所示,

var result = computer.Join(computerDetail,comp=>comp.id,compdet=>compdet.computerid,
         (comp,compdet)=> new 
                         {
                           Manufacturer = compdet.manufacture,
                           Model = compdet.model,
                           ... //more properties to select
                         }).ToList();

这将为您 return 您 anonymous 对象的列表。