在linq中将sql查询转换为linq new

问题描述 投票:0回答:1

因为我是linq的新手你可以帮我转换下面的SQL查询到linq。

Select o.* from [Order] o Left Join TransactionsTable yo on o.Id = yo.OrderId                           
Where yo.OrderId is null and Convert(date,o.CreatedOnUtc) = 
Convert(date,getutcdate()) and  o.OrderStatusId = 1
asp.net linq linq-to-sql
1个回答
0
投票

你可以试试这个。

var q = from o in Orders
         join yo in TransactionsTables on o.Id equals yo.OrderId into tt
         from yo in tt.DefaultIfEmpty()
       where !yo.OrderId.HasValue 
          && o.CreatedOnUtc.Value.Date == DateTime.UtcNow.Date
          && o.OrderStatusId == 1
       select o ;
© www.soinside.com 2019 - 2024. All rights reserved.