• linq not in 查询


    想要的sql:

    select A.* from BL_BCSS_Invoice A join BL_BCSS_OfflineInvoice B on A.ID!=B.InvoiceID;

    不知道如何写的linq.....

    from t1 in BL_BCSS_Invoice

    from t2 in BL_BCSS_OfflineInvoice

    where t1.ID != t2.InvoiceID

    select t1;

    linq not in 查询 or join not in

    var query = from c in _opvRepository.Table
                            join a in _orderRepository.Table on c.OrderId equals a.Id
                            join p in _pvRepository.Table on c.ProductVariantId equals p.Id
                            join e in _productRepository.Table on p.ProductId equals e.Id                     
                            where a.CustomerId == customerId & !(from s in _productReviewRepository.Table select s.ProductId).Contains(a.CustomerId & p.ProductId)
                            select new CustomerChapter()
                            {
                                Name = p.Name,
                                ProdcutName = e.Name,
                                CreatedOn = a.CreatedOnUtc,
                                ProductId = p.ProductId,
                                Id = a.CustomerId,
                            };

    生成的sql 语句如下

    SELECT 
    [Filter2].[OrderId] AS [OrderId], 
    [Filter2].[Name] AS [Name], 
    [Extent4].[Name] AS [Name1], 
    [Filter2].[CreatedOnUtc1] AS [CreatedOnUtc], 
    [Filter2].[ProductId] AS [ProductId], 
    [Filter2].[CustomerId] AS [CustomerId]
    FROM   (SELECT [Extent1].[OrderId] AS [OrderId], [Extent2].[CustomerId] AS [CustomerId], [Extent2].[CreatedOnUtc] AS [CreatedOnUtc1], [Extent3].[ProductId] AS [ProductId], [Extent3].[Name] AS [Name]
     FROM   [dbo].[OrderProductVariant] AS [Extent1]
     INNER JOIN [dbo].[Order] AS [Extent2] ON [Extent1].[OrderId] = [Extent2].[Id]
     INNER JOIN [dbo].[ProductVariant] AS [Extent3] ON [Extent1].[ProductVariantId] = [Extent3].[Id]
     WHERE  NOT EXISTS (SELECT 
      1 AS [C1]
      FROM  ( SELECT 1 AS X ) AS [SingleRowTable1]
      WHERE 1 = 0
     ) ) AS [Filter2]
    INNER JOIN [dbo].[Product] AS [Extent4] ON [Filter2].[ProductId] = [Extent4].[Id]
    WHERE [Filter2].[CustomerId] = 1
    
  • 相关阅读:
    celery 大量消息的分布式系统 定时任务
    小程序开发-生活娱乐两不误
    linux安装selenium+chrome+phantomjs
    CENTOS 7 安装 TINYPROXY 代理服务器
    JVM(三) 垃圾回收时间点和垃圾收集器
    JDK12 concurrenthashmap源码阅读
    JVM(二) 对象存活判断和垃圾回收算法
    java 线程池(2)
    JVM(一)
    java 线程池(1)
  • 原文地址:https://www.cnblogs.com/sunShineJing/p/10382858.html
Copyright © 2020-2023  润新知