سلام چطوری میشه یه query مثل این رو به linq تبدیل نمود ؟
SELECT ProductsExportID, Fname,Lname,InsuranceName,dbo.[Order].ProductID,ProductName,Price,SUM(PrTotalExport) AS PRCuont, SUM(Price) AS PRPrice,SUM(Price * PrTotalExport) AS TotalPrice FROM dbo.ProductsExport INNER JOIN dbo.[Order] ON [Order].OrderID = ProductsExport.OrderID INNER JOIN dbo.Products ON Products.ProductID = ProductsExport.ProductID INNER JOIN dbo.Customer ON Customer.CustomerID = [Order].CustomerID INNER JOIN dbo.Insurance ON Insurance.InsuranceID = Customer.InsuranceID GROUP BY ProductsExportID, Fname,Lname,InsuranceName,dbo.[Order].ProductID,ProductName,Price,PrTotalExport,ProductsExport.OrderID ORDER BY ProductID
تا اینجا تبدیل شده
var res = from e in db.ProductsExports
join o in db.Orders on e.OrderID equals o.OrderID
join c in db.Customers on o.CustomerID equals c.CustomerID
join p in db.Products on o.ProductID equals p.ProductID
join i in db.Insurances on c.InsuranceID equals i.InsuranceID
select new { e.ProductsExportID, c.Fname, c.Lname, p.ProductID, p.Price, e.PrTotalExport } into x
group x by new { x.ProductsExportID, x.Fname, x.Lname, x.ProductID, x.Price, x.PrTotalExport }into g
select new
{
gProductsExportID = g,
gFname = g.Fname,
gLname=g.Lname,
gprid=g.ProductID,
gprice=g.Price,
gTotalpr=g.PrTotalExport,
};
ولی جواب نداد
از نرم افزار Linqer استفاده کنید
کوئری های Sql را به Linq تبدیل میکنه
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)