SelectMany - Compound from 3

Query
public void Linq16()
{
List customers = GetCustomerList();

var orders =
from c in customers
from o in c.Orders
where o.OrderDate >= new DateTime(1998, 1, 1)
select new { c.CustomerID, o.OrderID, o.OrderDate };

ObjectDumper.Write(orders);
}
Lambda Expression
public void DataSetLinq16()
{
var customers = testDS.Tables["Customers"].AsEnumerable();
var orders = testDS.Tables["Orders"].AsEnumerable();

var myOrders =
customers.SelectMany(c => orders, (c, o) => new {c, o}).
Where(@t => @t.c.Field("CustomerID") == @t.o.Field("CustomerID") && @t.o.Field("OrderDate") >= new DateTime(1998, 1, 1)).
Select(@t => new {
CustomerID = @t.c.Field("CustomerID"),
OrderID = @t.o.Field("OrderID"),
OrderDate = @t.o.Field("OrderDate")});
ObjectDumper.Write(myOrders);
}
Output
CustomerID=ALFKI OrderID=10835 OrderDate=1/15/1998
CustomerID=ALFKI OrderID=10952 OrderDate=3/16/1998
CustomerID=ALFKI OrderID=11011 OrderDate=4/9/1998
CustomerID=ANATR OrderID=10926 OrderDate=3/4/1998
CustomerID=ANTON OrderID=10856 OrderDate=1/28/1998
CustomerID=AROUT OrderID=10864 OrderDate=2/2/1998
CustomerID=AROUT OrderID=10920 OrderDate=3/3/1998
CustomerID=AROUT OrderID=10953 OrderDate=3/16/1998
CustomerID=AROUT OrderID=11016 OrderDate=4/10/1998
CustomerID=BERGS OrderID=10837 OrderDate=1/16/1998
CustomerID=BERGS OrderID=10857 OrderDate=1/28/1998
CustomerID=BERGS OrderID=10866 OrderDate=2/3/1998
CustomerID=BERGS OrderID=10875 OrderDate=2/6/1998
CustomerID=BERGS OrderID=10924 OrderDate=3/4/1998
CustomerID=BLAUS OrderID=10853 OrderDate=1/27/1998
CustomerID=BLAUS OrderID=10956 OrderDate=3/17/1998
CustomerID=BLAUS OrderID=11058 OrderDate=4/29/1998
CustomerID=BLONP OrderID=10826 OrderDate=1/12/1998
CustomerID=BOLID OrderID=10970 OrderDate=3/24/1998
CustomerID=BONAP OrderID=10827 OrderDate=1/12/1998
CustomerID=BONAP OrderID=10871 OrderDate=2/5/1998
CustomerID=BONAP OrderID=10876 OrderDate=2/9/1998
CustomerID=BONAP OrderID=10932 OrderDate=3/6/1998
CustomerID=BONAP OrderID=10940 OrderDate=3/11/1998
CustomerID=BONAP OrderID=11076 OrderDate=5/6/1998
CustomerID=BOTTM OrderID=10918 OrderDate=3/2/1998
CustomerID=BOTTM OrderID=10944 OrderDate=3/12/1998
CustomerID=BOTTM OrderID=10949 OrderDate=3/13/1998
CustomerID=BOTTM OrderID=10975 OrderDate=3/25/1998
CustomerID=BOTTM OrderID=10982 OrderDate=3/27/1998
CustomerID=BOTTM OrderID=11027 OrderDate=4/16/1998
CustomerID=BOTTM OrderID=11045 OrderDate=4/23/1998
CustomerID=BOTTM OrderID=11048 OrderDate=4/24/1998
CustomerID=BSBEV OrderID=10943 OrderDate=3/11/1998
CustomerID=BSBEV OrderID=10947 OrderDate=3/13/1998
CustomerID=BSBEV OrderID=11023 OrderDate=4/14/1998
CustomerID=CACTU OrderID=10819 OrderDate=1/7/1998
CustomerID=CACTU OrderID=10881 OrderDate=2/11/1998
CustomerID=CACTU OrderID=10937 OrderDate=3/10/1998
CustomerID=CACTU OrderID=11054 OrderDate=4/28/1998
CustomerID=CHOPS OrderID=10966 OrderDate=3/20/1998
CustomerID=CHOPS OrderID=11029 OrderDate=4/16/1998
CustomerID=CHOPS OrderID=11041 OrderDate=4/22/1998
CustomerID=COMMI OrderID=10969 OrderDate=3/23/1998
CustomerID=COMMI OrderID=11042 OrderDate=4/22/1998
CustomerID=CONSH OrderID=10848 OrderDate=1/23/1998
CustomerID=DRACD OrderID=10825 OrderDate=1/9/1998
CustomerID=DRACD OrderID=11036 OrderDate=4/20/1998
CustomerID=DRACD OrderID=11067 OrderDate=5/4/1998
CustomerID=DUMON OrderID=10890 OrderDate=2/16/1998
CustomerID=EASTC OrderID=10987 OrderDate=3/31/1998
CustomerID=EASTC OrderID=11024 OrderDate=4/15/1998
CustomerID=EASTC OrderID=11047 OrderDate=4/24/1998
CustomerID=EASTC OrderID=11056 OrderDate=4/28/1998
CustomerID=ERNSH OrderID=10836 OrderDate=1/16/1998
CustomerID=ERNSH OrderID=10854 OrderDate=1/27/1998
CustomerID=ERNSH OrderID=10895 OrderDate=2/18/1998
CustomerID=ERNSH OrderID=10968 OrderDate=3/23/1998
CustomerID=ERNSH OrderID=10979 OrderDate=3/26/1998
CustomerID=ERNSH OrderID=10990 OrderDate=4/1/1998
CustomerID=ERNSH OrderID=11008 OrderDate=4/8/1998
CustomerID=ERNSH OrderID=11017 OrderDate=4/13/1998
CustomerID=ERNSH OrderID=11072 OrderDate=5/5/1998
CustomerID=FOLKO OrderID=10824 OrderDate=1/9/1998
CustomerID=FOLKO OrderID=10880 OrderDate=2/10/1998
CustomerID=FOLKO OrderID=10902 OrderDate=2/23/1998
CustomerID=FOLKO OrderID=10955 OrderDate=3/17/1998
CustomerID=FOLKO OrderID=10977 OrderDate=3/26/1998
CustomerID=FOLKO OrderID=10980 OrderDate=3/27/1998
CustomerID=FOLKO OrderID=10993 OrderDate=4/1/1998
CustomerID=FOLKO OrderID=11001 OrderDate=4/6/1998
CustomerID=FOLKO OrderID=11050 OrderDate=4/27/1998
CustomerID=FRANK OrderID=10859 OrderDate=1/29/1998
CustomerID=FRANK OrderID=10929 OrderDate=3/5/1998
CustomerID=FRANK OrderID=11012 OrderDate=4/9/1998
CustomerID=FRANR OrderID=10860 OrderDate=1/29/1998
CustomerID=FRANR OrderID=10971 OrderDate=3/24/1998
CustomerID=FRANS OrderID=11026 OrderDate=4/15/1998
CustomerID=FRANS OrderID=11060 OrderDate=4/30/1998
CustomerID=FURIB OrderID=10963 OrderDate=3/19/1998
CustomerID=GALED OrderID=10887 OrderDate=2/13/1998
CustomerID=GALED OrderID=10928 OrderDate=3/5/1998
CustomerID=GODOS OrderID=10872 OrderDate=2/5/1998
CustomerID=GODOS OrderID=10874 OrderDate=2/6/1998
CustomerID=GODOS OrderID=10888 OrderDate=2/16/1998
CustomerID=GODOS OrderID=10911 OrderDate=2/26/1998
CustomerID=GODOS OrderID=10948 OrderDate=3/13/1998
CustomerID=GODOS OrderID=11009 OrderDate=4/8/1998
CustomerID=GODOS OrderID=11037 OrderDate=4/21/1998
CustomerID=GOURL OrderID=10959 OrderDate=3/18/1998
CustomerID=GOURL OrderID=11049 OrderDate=4/24/1998
CustomerID=GREAL OrderID=10816 OrderDate=1/6/1998
CustomerID=GREAL OrderID=10936 OrderDate=3/9/1998
CustomerID=GREAL OrderID=11006 OrderDate=4/7/1998
CustomerID=GREAL OrderID=11040 OrderDate=4/22/1998
CustomerID=GREAL OrderID=11061 OrderDate=4/30/1998
CustomerID=HANAR OrderID=10886 OrderDate=2/13/1998
CustomerID=HANAR OrderID=10903 OrderDate=2/24/1998
CustomerID=HANAR OrderID=10922 OrderDate=3/3/1998
CustomerID=HANAR OrderID=10925 OrderDate=3/4/1998
CustomerID=HANAR OrderID=10981 OrderDate=3/27/1998
CustomerID=HANAR OrderID=11022 OrderDate=4/14/1998
CustomerID=HANAR OrderID=11052 OrderDate=4/27/1998
CustomerID=HILAA OrderID=10863 OrderDate=2/2/1998
CustomerID=HILAA OrderID=10901 OrderDate=2/23/1998
CustomerID=HILAA OrderID=10957 OrderDate=3/18/1998
CustomerID=HILAA OrderID=10960 OrderDate=3/19/1998
CustomerID=HILAA OrderID=10976 OrderDate=3/25/1998
CustomerID=HILAA OrderID=11055 OrderDate=4/28/1998
CustomerID=HUNGO OrderID=10897 OrderDate=2/19/1998
CustomerID=HUNGO OrderID=10912 OrderDate=2/26/1998
CustomerID=HUNGO OrderID=10985 OrderDate=3/30/1998
CustomerID=HUNGO OrderID=11063 OrderDate=4/30/1998
CustomerID=ISLAT OrderID=10829 OrderDate=1/13/1998
CustomerID=ISLAT OrderID=10933 OrderDate=3/6/1998
CustomerID=KOENE OrderID=10817 OrderDate=1/6/1998
CustomerID=KOENE OrderID=10849 OrderDate=1/23/1998
CustomerID=KOENE OrderID=10893 OrderDate=2/18/1998
CustomerID=KOENE OrderID=11028 OrderDate=4/16/1998
CustomerID=LACOR OrderID=10858 OrderDate=1/29/1998
CustomerID=LACOR OrderID=10927 OrderDate=3/5/1998
CustomerID=LACOR OrderID=10972 OrderDate=3/24/1998
CustomerID=LACOR OrderID=10973 OrderDate=3/24/1998
CustomerID=LAMAI OrderID=10832 OrderDate=1/14/1998
CustomerID=LAMAI OrderID=10923 OrderDate=3/3/1998
CustomerID=LAMAI OrderID=11051 OrderDate=4/27/1998
CustomerID=LAUGB OrderID=10810 OrderDate=1/1/1998
CustomerID=LEHMS OrderID=10862 OrderDate=1/30/1998
CustomerID=LEHMS OrderID=10891 OrderDate=2/17/1998
CustomerID=LEHMS OrderID=10934 OrderDate=3/9/1998
CustomerID=LEHMS OrderID=11070 OrderDate=5/5/1998
CustomerID=LETSS OrderID=10884 OrderDate=2/12/1998
CustomerID=LILAS OrderID=10823 OrderDate=1/9/1998
CustomerID=LILAS OrderID=10899 OrderDate=2/20/1998
CustomerID=LILAS OrderID=10997 OrderDate=4/3/1998
CustomerID=LILAS OrderID=11065 OrderDate=5/1/1998
CustomerID=LILAS OrderID=11071 OrderDate=5/5/1998
CustomerID=LINOD OrderID=10811 OrderDate=1/2/1998
CustomerID=LINOD OrderID=10838 OrderDate=1/19/1998
CustomerID=LINOD OrderID=10840 OrderDate=1/19/1998
CustomerID=LINOD OrderID=10919 OrderDate=3/2/1998
CustomerID=LINOD OrderID=10954 OrderDate=3/17/1998
CustomerID=LINOD OrderID=11014 OrderDate=4/10/1998
CustomerID=LINOD OrderID=11039 OrderDate=4/21/1998
CustomerID=LONEP OrderID=10867 OrderDate=2/3/1998
CustomerID=LONEP OrderID=10883 OrderDate=2/12/1998
CustomerID=LONEP OrderID=11018 OrderDate=4/13/1998
CustomerID=MAGAA OrderID=10818 OrderDate=1/7/1998
CustomerID=MAGAA OrderID=10939 OrderDate=3/10/1998
CustomerID=MAGAA OrderID=10950 OrderDate=3/16/1998
CustomerID=MAISD OrderID=10892 OrderDate=2/17/1998
CustomerID=MAISD OrderID=10896 OrderDate=2/19/1998
CustomerID=MAISD OrderID=10978 OrderDate=3/26/1998
CustomerID=MAISD OrderID=11004 OrderDate=4/7/1998
CustomerID=MORGK OrderID=10945 OrderDate=3/12/1998
CustomerID=NORTS OrderID=11057 OrderDate=4/29/1998
CustomerID=OCEAN OrderID=10898 OrderDate=2/20/1998
CustomerID=OCEAN OrderID=10958 OrderDate=3/18/1998
CustomerID=OCEAN OrderID=10986 OrderDate=3/30/1998
CustomerID=OLDWO OrderID=10855 OrderDate=1/27/1998
CustomerID=OLDWO OrderID=10965 OrderDate=3/20/1998
CustomerID=OLDWO OrderID=11034 OrderDate=4/20/1998
CustomerID=OTTIK OrderID=10833 OrderDate=1/15/1998
CustomerID=OTTIK OrderID=10999 OrderDate=4/3/1998
CustomerID=OTTIK OrderID=11020 OrderDate=4/14/1998
CustomerID=PERIC OrderID=10995 OrderDate=4/2/1998
CustomerID=PERIC OrderID=11073 OrderDate=5/5/1998
CustomerID=PICCO OrderID=10844 OrderDate=1/21/1998
CustomerID=PICCO OrderID=11053 OrderDate=4/27/1998
CustomerID=PRINI OrderID=10808 OrderDate=1/1/1998
CustomerID=PRINI OrderID=11007 OrderDate=4/8/1998
CustomerID=QUEDE OrderID=10989 OrderDate=3/31/1998
CustomerID=QUEEN OrderID=10868 OrderDate=2/4/1998
CustomerID=QUEEN OrderID=10913 OrderDate=2/26/1998
CustomerID=QUEEN OrderID=10914 OrderDate=2/27/1998
CustomerID=QUEEN OrderID=10961 OrderDate=3/19/1998
CustomerID=QUEEN OrderID=11068 OrderDate=5/4/1998
CustomerID=QUICK OrderID=10845 OrderDate=1/21/1998
CustomerID=QUICK OrderID=10865 OrderDate=2/2/1998
CustomerID=QUICK OrderID=10878 OrderDate=2/10/1998
CustomerID=QUICK OrderID=10938 OrderDate=3/10/1998
CustomerID=QUICK OrderID=10962 OrderDate=3/19/1998
CustomerID=QUICK OrderID=10991 OrderDate=4/1/1998
CustomerID=QUICK OrderID=10996 OrderDate=4/2/1998
CustomerID=QUICK OrderID=11021 OrderDate=4/14/1998
CustomerID=RANCH OrderID=10828 OrderDate=1/13/1998
CustomerID=RANCH OrderID=10916 OrderDate=2/27/1998
CustomerID=RANCH OrderID=11019 OrderDate=4/13/1998
CustomerID=RATTC OrderID=10820 OrderDate=1/7/1998
CustomerID=RATTC OrderID=10852 OrderDate=1/26/1998
CustomerID=RATTC OrderID=10889 OrderDate=2/16/1998
CustomerID=RATTC OrderID=10988 OrderDate=3/31/1998
CustomerID=RATTC OrderID=11000 OrderDate=4/6/1998
CustomerID=RATTC OrderID=11077 OrderDate=5/6/1998
CustomerID=REGGC OrderID=10812 OrderDate=1/2/1998
CustomerID=REGGC OrderID=10908 OrderDate=2/26/1998
CustomerID=REGGC OrderID=10942 OrderDate=3/11/1998
CustomerID=REGGC OrderID=11010 OrderDate=4/9/1998
CustomerID=REGGC OrderID=11062 OrderDate=4/30/1998
CustomerID=RICAR OrderID=10813 OrderDate=1/5/1998
CustomerID=RICAR OrderID=10851 OrderDate=1/26/1998
CustomerID=RICAR OrderID=10877 OrderDate=2/9/1998
CustomerID=RICAR OrderID=11059 OrderDate=4/29/1998
CustomerID=RICSU OrderID=10931 OrderDate=3/6/1998
CustomerID=RICSU OrderID=10951 OrderDate=3/16/1998
CustomerID=RICSU OrderID=11033 OrderDate=4/17/1998
CustomerID=RICSU OrderID=11075 OrderDate=5/6/1998
CustomerID=ROMEY OrderID=10917 OrderDate=3/2/1998
CustomerID=ROMEY OrderID=11013 OrderDate=4/9/1998
CustomerID=SANTG OrderID=10831 OrderDate=1/14/1998
CustomerID=SANTG OrderID=10909 OrderDate=2/26/1998
CustomerID=SANTG OrderID=11015 OrderDate=4/10/1998
CustomerID=SAVEA OrderID=10815 OrderDate=1/5/1998
CustomerID=SAVEA OrderID=10847 OrderDate=1/22/1998
CustomerID=SAVEA OrderID=10882 OrderDate=2/11/1998
CustomerID=SAVEA OrderID=10894 OrderDate=2/18/1998
CustomerID=SAVEA OrderID=10941 OrderDate=3/11/1998
CustomerID=SAVEA OrderID=10983 OrderDate=3/27/1998
CustomerID=SAVEA OrderID=10984 OrderDate=3/30/1998
CustomerID=SAVEA OrderID=11002 OrderDate=4/6/1998
CustomerID=SAVEA OrderID=11030 OrderDate=4/17/1998
CustomerID=SAVEA OrderID=11031 OrderDate=4/17/1998
CustomerID=SAVEA OrderID=11064 OrderDate=5/1/1998
CustomerID=SEVES OrderID=10869 OrderDate=2/4/1998
CustomerID=SIMOB OrderID=11074 OrderDate=5/6/1998
CustomerID=SPECD OrderID=10907 OrderDate=2/25/1998
CustomerID=SPECD OrderID=10964 OrderDate=3/20/1998
CustomerID=SPECD OrderID=11043 OrderDate=4/22/1998
CustomerID=SPLIR OrderID=10821 OrderDate=1/8/1998
CustomerID=SPLIR OrderID=10974 OrderDate=3/25/1998
CustomerID=SUPRD OrderID=10841 OrderDate=1/20/1998
CustomerID=SUPRD OrderID=10846 OrderDate=1/22/1998
CustomerID=SUPRD OrderID=10885 OrderDate=2/12/1998
CustomerID=SUPRD OrderID=10930 OrderDate=3/6/1998
CustomerID=SUPRD OrderID=11035 OrderDate=4/20/1998
CustomerID=SUPRD OrderID=11038 OrderDate=4/21/1998
CustomerID=THEBI OrderID=10992 OrderDate=4/1/1998
CustomerID=THECR OrderID=11003 OrderDate=4/6/1998
CustomerID=TOMSP OrderID=10967 OrderDate=3/23/1998
CustomerID=TORTU OrderID=10842 OrderDate=1/20/1998
CustomerID=TORTU OrderID=10915 OrderDate=2/27/1998
CustomerID=TORTU OrderID=11069 OrderDate=5/4/1998
CustomerID=TRADH OrderID=10830 OrderDate=1/13/1998
CustomerID=TRADH OrderID=10834 OrderDate=1/15/1998
CustomerID=TRADH OrderID=10839 OrderDate=1/19/1998
CustomerID=TRAIH OrderID=10822 OrderDate=1/8/1998
CustomerID=VAFFE OrderID=10921 OrderDate=3/3/1998
CustomerID=VAFFE OrderID=10946 OrderDate=3/12/1998
CustomerID=VAFFE OrderID=10994 OrderDate=4/2/1998
CustomerID=VICTE OrderID=10814 OrderDate=1/5/1998
CustomerID=VICTE OrderID=10843 OrderDate=1/21/1998
CustomerID=VICTE OrderID=10850 OrderDate=1/23/1998
CustomerID=WANDK OrderID=11046 OrderDate=4/23/1998
CustomerID=WARTH OrderID=11025 OrderDate=4/15/1998
CustomerID=WELLI OrderID=10809 OrderDate=1/1/1998
CustomerID=WELLI OrderID=10900 OrderDate=2/20/1998
CustomerID=WELLI OrderID=10905 OrderDate=2/24/1998
CustomerID=WELLI OrderID=10935 OrderDate=3/9/1998
CustomerID=WHITC OrderID=10861 OrderDate=1/30/1998
CustomerID=WHITC OrderID=10904 OrderDate=2/24/1998
CustomerID=WHITC OrderID=11032 OrderDate=4/17/1998
CustomerID=WHITC OrderID=11066 OrderDate=5/1/1998
CustomerID=WILMK OrderID=10873 OrderDate=2/6/1998
CustomerID=WILMK OrderID=10879 OrderDate=2/10/1998
CustomerID=WILMK OrderID=10910 OrderDate=2/26/1998
CustomerID=WILMK OrderID=11005 OrderDate=4/7/1998
CustomerID=WOLZA OrderID=10870 OrderDate=2/4/1998
CustomerID=WOLZA OrderID=10906 OrderDate=2/25/1998
CustomerID=WOLZA OrderID=10998 OrderDate=4/3/1998
CustomerID=WOLZA OrderID=11044 OrderDate=4/23/1998
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +