मैं LINQ में यह कैसे कर सकता हूं?LINQ; जुड़ने के साथ अधिकतम तिथि के साथ रिकॉर्ड कैसे प्राप्त करें?
select
*
from customer c
left join order o on o.CustomerID = c.CustomerID
where o.OrderDate = (select MAX(OrderDate) from order where CustomerID = o.CustomerID)
डुप्लिकेट के बारे में चिंतित नहीं है क्योंकि हमेशा प्रति दिन केवल एक आदेश होगा।
var query = from customer in clist
from order in olist
.Where(o => o.CustomerID == customer.CustomerID && o.OrderDate ==
olist.Where(o1 => o1.CustomerID == customer.CustomerID).Max(o1 => o1.OrderDate)
)
select new {
customer.CustomerID,
customer.Name,
customer.Address,
order.Product,
order.OrderDate
};
किसी भी lambdas
बिना एक अन्य समाधान:मैं जहाँ तक छोड़ दिया के रूप में यकीन है कि कैसे या जहाँ में सबक्वेरी डाल करने के लिए अंतिम समाधान मिल गया LINQ में शामिल होने के लिए, लेकिन नहीं
var query = from customer in clist
from order in olist
.Where(o => o.CustomerID == customer.CustomerID)
select new {
customer.CustomerID,
customer.Name,
customer.Address,
Product = order != null ? order.Product : string.Empty
};
।
var query = from customer in clist
from order in olist
where order.CustomerID == customer.CustomerID && order.OrderDate ==
(from o in olist
where o.CustomerID == customer.CustomerID
select o.OrderDate).Max()
select new {
customer.CustomerID,
customer.Name,
customer.Address,
order.Product,
order.OrderDate
};
धन्यवाद, मेरा अंतिम समाधान शाब्दिक परिवर्तन पर आधारित है। – mfc