public IEnumerable
GetOrderDetails(int orderID)
{
NorthwindDataContext db = this.DataContext;
IEnumerable orderDetails =
from o in db.Orders
where o.OrderID == orderID
join s in db.Shippers on o.ShipVia equals s.ShipperID
join od in db.OrderDetails on o.OrderID equals od.OrderID
join p in db.Products on od.ProductID equals p.ProductID
join supplier in db.Suppliers on p.SupplierID equals supplier.SupplierID
let total = od.Quantity * od.UnitPrice
select new OrderDescription
{
Product = p.ProductName,
Quantity = od.Quantity,
ShipperName = s.CompanyName,
Total = total,
UnitPrice = od.UnitPrice,
SupplierName = supplier.CompanyName
};
return orderDetails;
}
Instead of using joins with the LINQ query expression it is also possible to use compound from and access shipper and supplier (with a * to 1 relation) directly:
public IEnumerable
GetOrderDetails(int orderID)
{
NorthwindDataContext db = this.DataContext;
IEnumerable orderDetails =
from o in db.Orders
where o.OrderID == orderID
from od in o.OrderDetails
let total = od.Quantity * od.UnitPrice
select new OrderDescription
{
Product = od.Product.ProductName,
Quantity = od.Quantity,
ShipperName = o.Shipper.CompanyName,
Total = total,
UnitPrice = od.UnitPrice,
SupplierName = od.Product.Supplier.CompanyName
};
return orderDetails;
}
I think the LINQ query with compound from is the simpler one.
Christian
It's really not fair to list this one because the site I'm referring to is still in development. It should launch in the next few weeks. I list it because it's going to be very "top 5" worthy when it launches.
Posted by: buy kamagra | 04/23/2010 at 07:57 PM
a haha. this is too much fun.
Posted by: ugg store | 11/06/2010 at 07:51 AM
^-^Many visitors are asking us about how this crisis will affect nonprofits.
Posted by: chaussure de basket | 12/02/2010 at 09:06 AM
Thank You for posting this. i really enjoyed reading this!!
Posted by: Chaussure Jordan | 12/02/2010 at 09:16 AM
When another person pays me an sudden compliment, I normally inform them that they created my day!
Posted by: chaussure basket | 12/02/2010 at 09:20 AM
To my mind it is a great article*.*
Posted by: Air Jordan Basket | 12/02/2010 at 09:27 AM
I find life an exciting business,The point is succinctness of expression.
Posted by: cl boots | 12/28/2010 at 09:40 AM
Hey, Really great work,I would like to join your blog anyway so please continue sharing with us..........
Posted by: Kamagra | 04/12/2011 at 09:40 AM
Really great work,I would like to join your blog anyway so please continue sharing with us.
http://www.redsolelouboutins.com/
http://www.louboutin4u.com/
Posted by: louboutin shoes | 04/13/2011 at 03:12 AM
Hi there,
Really nice job,There are many people searching about that now they will find enough sources by your tips.
Also looking forward for more tips about that
Posted by: ゼチーア | 05/13/2011 at 12:00 PM
Could I possibly repost this to one of my blogs on this subject? I will link back to the original, of course. Email me what you think.
Posted by: Christian Louboutin shoes | 05/18/2011 at 01:46 PM
Hey! I could have sworn I’ve been to this website before but after checking through some of the post I realized it’s new to me. Nonetheless, I’m definitely happy I found it and I’ll be bookmarking and checking back frequently!
Posted by: Vibram Five Fingers | 05/18/2011 at 01:47 PM
I personally believe there is a mojo to writing articles that only a few posses and frankly you have it , you genius;
Posted by: Vibram Five Fingers | 05/18/2011 at 01:48 PM
I don’t care how the others who commented here are feeling about your article – I still like it.
Posted by: supra shoes | 05/18/2011 at 01:48 PM
There's no word to describe such a great masterpiece. You made such an interesting piece to read, giving every subject an enlightenment for us to gain knowledge and information without any arguments to deal with. Thank you very much and more power!
Posted by: loans till payday | 06/16/2011 at 07:44 PM
I could tell that we’re on the same interest and obsession. Good to know someone I could share my ideas. Looking forward to know and learn some more from you. I'll be glad to share my own thoughts to you soon. Thank you for sharing such valuable articles. More power!
Posted by: irs back taxes | 06/20/2011 at 07:55 PM
There's no word to describe such a great masterpiece. You made such an interesting piece to read, giving every subject an enlightenment for us to gain knowledge and information without any arguments to deal with. Thank you very much and more power!
Posted by: android app developers | 06/20/2011 at 07:57 PM
Wow!! This is a nice blog and i am very impressed with your blog content. You have shared a nice information with us. I appreciate your work.
Posted by: Trade Forex | 07/02/2011 at 05:48 AM
Oh hey I wanted to take the time to say I really like reading your blog.
Posted by: pendant lighting | 07/31/2011 at 04:51 AM
I wanted to take the time to say I really like reading your blog.
Posted by: Alexander McQueen Shoes | 08/25/2011 at 10:19 AM
Details are very true and factual, I do really learned something new upon reading this interesting post. Good job! and Thanks!
Posted by: SEO Services Company | 08/26/2011 at 01:12 PM
This blog is an exact representation of skills. I appreciate the blogger for posting the most excellent thought.
Posted by: Cheap Logo Design | 09/29/2011 at 07:31 AM
I like ANMJ on FB & just subscribed to the email feed! :)
Posted by: red bottom heel | 10/13/2011 at 05:06 PM
Nice stuff you got, very interesting to read.Well, I do have also in my sleeves, if you have
time don't forget to visit
Spring Electrician
Posted by: sonia | 02/01/2012 at 10:22 AM
Thank you for sharing such great information with us. I really appreciate everything that you've done here and am glad to know that you really care about the world that we live in..
Posted by: Buy Abilify Online US pharmacy | 02/18/2012 at 07:45 AM