首页 > 代码库 > LINQ系列:LINQ to SQL Join连接

LINQ系列:LINQ to SQL Join连接

1. 一对多

var expr = context.Products    .Where(p => p.Category.CategoryName == "LINQ to SQL" && p.UnitPrice > 10m)    .Select(p => new    {        p.ProductID,        p.ProductName    });
var expr = from p in context.Products            where p.Category.CategoryName == "LINQ to SQL" && p.UnitPrice > 10m            select new            {                p.ProductID,                p.ProductName            };
SELECT     [Extent1].[ProductID] AS [ProductID],     [Extent1].[ProductName] AS [ProductName]    FROM  [dbo].[Product] AS [Extent1]    INNER JOIN [dbo].[Category] AS [Extent2] ON [Extent1].[CategoryID] = [Extent2].[CategoryID]    WHERE (NLINQ to SQL = [Extent2].[CategoryName]) AND ([Extent1].[UnitPrice] > cast(10 as decimal(18)))

 

LINQ系列:LINQ to SQL Join连接