This looks like it might be the tweak you need. It's from a very helpful LINQ sample site This sample prints the customer ID, order ID, and order date for the first three orders from customers in Washington. The sample uses Take to limit the sequence generated by the query expression to the first three of the orders public void Linq21() { List customers = GetCustomerList(); var first3WAOrders = ( from c in customers from o in c.
Orders where c. Region == "WA" select new {c. CustomerID, o.
OrderID, o. OrderDate} ) . Take(3); Console.
WriteLine("First 3 orders in WA:"); foreach (var order in first3WAOrders) { ObjectDumper. Write(order); } } Result First 3 orders in WA: CustomerID=LAZYK OrderID=10482 OrderDate=3/21/1997 CustomerID=LAZYK OrderID=10545 OrderDate=5/22/1997 CustomerID=TRAIH OrderID=10574 OrderDate=6/19/1997.
This looks like it might be the tweak you need. It's from a very helpful LINQ sample site. This sample prints the customer ID, order ID, and order date for the first three orders from customers in Washington.
The sample uses Take to limit the sequence generated by the query expression to the first three of the orders. Public void Linq21() { List customers = GetCustomerList(); var first3WAOrders = ( from c in customers from o in c. Orders where c.
Region == "WA" select new {c. CustomerID, o. OrderID, o.
OrderDate} ) . Take(3); Console. WriteLine("First 3 orders in WA:"); foreach (var order in first3WAOrders) { ObjectDumper.
Write(order); } } Result First 3 orders in WA: CustomerID=LAZYK OrderID=10482 OrderDate=3/21/1997 CustomerID=LAZYK OrderID=10545 OrderDate=5/22/1997 CustomerID=TRAIH OrderID=10574 OrderDate=6/19/1997.
I tried the following (based on above) var query = (from g in galleries from I in g. GalleryImages from c in g. Comments where i.galleryid.
Equals(g. Id) where c.galleryid. Equals(g.Id) select g).
Take(2); But this is simply doing the . Take(2) on the gallery table. Therefore I am now only getting 2 galleries.
– Robsimm May 23 '09 at 22:04 You started off with Take(3) and now you're doing Take(2)? – DOK May 23 '09 at 22:48 The sample above was merely an example. Thanks very much for your reply.
– Robsimm May 24 '09 at 7:58.
I managed to get it to work with: Table galleries = pdc.GetTable(); Table images = pdc.GetTable(); Table comments = pdc.GetTable(); var query = from gallery in galleries join image in images on gallery. Id equals image. Galleryid into joinedimages join comment in comments on gallery.Id equals comment.
Galleryid into joinedcomments select new { name = gallery. Name, wheretaken = gallery. Wheretaken, id = gallery.
Id, GalleryImages = joinedimages, Comments = joinedcomments. Take(3) }; gallst. DataSource = query; gallst.DataBind(); With the take taken place on the select.
Thanks for your help everyone. Any suggestions on how to write this "better" would be appreciated.
In terms of it being better, if you setup the foreign key relationships in your database then you don't have to explicitly do the joins in your code. – Jarrett Widman May 24 '09 at 5:43 So I have a foreign key relationship on all of the tables used in my example. How do I (in LINQ) represent this instead of doing the joins above?
– Robsimm May 24 '09 at 7:59.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.