简体   繁体   中英

How can I convert this sql statement to linq expression

How can I convert this sql query to linq expression, I'm new in linq and searched this but I could not understand how to convert it.

SELECT 
   a.afiliacaoid,
   DATE_FORMAT(a.horario, '%d/%m/%Y') data,
   COUNT(a.afiliacaoid) acessos,
   IFNULL(p.pedidos,0) pedidos
FROM 
   acesso a LEFT JOIN 
       (SELECT p.afiliacaoid, 
           DATE_FORMAT(p.cadastro , '%d/%m/%Y') data, 
           COUNT(p.afiliacaoid) pedidos 
           FROM pedido p) p ON a.afiliacaoid = p.afiliacaoid 
               AND DATE_FORMAT(a.horario, '%d/%m/%Y') = data
WHERE 
   a.afiliacaoid=1
   GROUP BY DATE_FORMAT(a.horario, '%d/%m/%Y')

我建议使用此工具进行转换: https : //www.linqpad.net/

这是一个很好的工具,可能对您有帮助-http: //www.sqltolinq.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM