C# LINQ等价MYSQL查询

C# LINQ等价MYSQL查询,c#,mysql,linq,asp.net-mvc-4,C#,Mysql,Linq,Asp.net Mvc 4,我使用MySQL数据库在一个旧的经典asp应用程序中使用以下查询生成一个报告。现在我想将其转换为MVC4应用程序。我非常需要帮助,以获得与linq相当的帮助。查询工作正常,如有任何帮助,将不胜感激 SELECT report_date.rep_year, report_date.rep_month, bob.salecnt, bob.Tsales, cob.Tgift, cob.TGiftSum, dob.Ttgift, dob.TtGiftSum FROM report_date

我使用MySQL数据库在一个旧的经典asp应用程序中使用以下查询生成一个报告。现在我想将其转换为MVC4应用程序。我非常需要帮助,以获得与linq相当的帮助。查询工作正常,如有任何帮助,将不胜感激

      SELECT report_date.rep_year, report_date.rep_month, bob.salecnt, bob.Tsales, cob.Tgift, cob.TGiftSum, dob.Ttgift, dob.TtGiftSum 
FROM report_date
LEFT OUTER JOIN
(
    SELECT year(x.s_date) AS rep_year, Month(x.s_date) AS rep_month, sum(x.bk_qty) as salecnt, sum(x.bk_qty*x.s_price) as Tsales 
    FROM sale x 
    WHERE x.s_date <= curdate() 
    and x.s_date >'2010-10-31' 
    GROUP BY rep_year, rep_month
)as bob
ON bob.rep_year = report_date.rep_year
AND bob.rep_month = report_date.rep_month
LEFT OUTER JOIN
(
    SELECT year(y.gDate) AS rep_year, Month(y.gDate) AS rep_month, sum(y.gQty) as Tgift, sum(y.gQty*y.gPrice)as TGiftSum 
    From  gift y 
    WHERE  y.gbktype =1 
    and y.gdate <= curdate() 
    and y.gdate>'2010-10-31' 
    GROUP BY rep_year, rep_month
)as cob
ON cob.rep_year = report_date.rep_year
AND cob.rep_month = report_date.rep_month
LEFT OUTER JOIN
(
    SELECT year(z.gdate) AS rep_year, Month(z.gdate) AS rep_month, sum(z.gQty) as Ttgift, sum(z.gQty*z.gprice)as TtGiftSum 
    From  gift z 
    WHERE z.gbktype =2 
    and z.gdate <= curdate() 
    and z.gDate>'2010-10-31' 
    GROUP BY rep_year, rep_month 
)as dob 
ON dob.rep_year = report_date.rep_year
AND dob.rep_month = report_date.rep_month
WHERE CONCAT(report_date.rep_year, report_date.rep_month) > '201010'
AND CONCAT(report_date.rep_year, report_date.rep_month) <= DATE_FORMAT(CURDATE(), '%Y%m')
从MSDN:

LINQ选择示例:

IEnumerable<int> squares =
                Enumerable.Range(1, 10).Select(x => x * x);

            foreach (int num in squares)
            {
                Console.WriteLine(num);
            }
            /*
             This code produces the following output:

             1
             4
             9
             16
             25
             36
             49
             64
             81
             100
            */
MSDN链接供参考:

到目前为止,您尝试了什么?您自己尝试这样做时遇到的具体问题是什么?请在你的问题上更加具体,而不仅仅是要求S.O.为你做工作。哈哈。请将我的250行SQL查询转换为LINQ。是的,我愿意那样做。这是令人兴奋的,但我最终会到达那里的。谢谢你的指导,至少现在我知道了如何解决这个问题。没问题,很乐意帮忙
IEnumerable<int> squares =
                Enumerable.Range(1, 10).Select(x => x * x);

            foreach (int num in squares)
            {
                Console.WriteLine(num);
            }
            /*
             This code produces the following output:

             1
             4
             9
             16
             25
             36
             49
             64
             81
             100
            */
var innerGroupJoinQuery2 =
    from category in categories
    join prod in products on category.ID equals prod.CategoryID into prodGroup
    from prod2 in prodGroup
    where prod2.UnitPrice > 2.50M
    select prod2;