LLBLgen creates a sub query with n parameters (in this example n = 49) :
new LinqMetaData()
.Card
.Select(c => new
{
CardId = c.CardID,
Products = c.Products.Select(p => new { ProductId = p.ProductID })
})
.Take(49) //n
.Dump();
LLBLGen creates two queries. First query (generated by LLBLGen):
SELECT "LPLA_1"."CARDID" AS "CardId",
1 AS "LPFA_2",
"LPLA_1"."CARDID" AS "CardID"
FROM "CARD" "LPLA_1"
WHERE rownum <= 49
second query (containing 49 parameters - generated by LLBLGen):
SELECT "LPLA_2"."PRODUCTID" AS "ProductId",
"LPLA_2"."CARDID" AS "CardID"
FROM "PRODUCT" "LPLA_2"
WHERE ((("LPLA_2"."CARDID" IN (:p1, :p2, :p3, :p4,
:p5, :p6, :p7, :p8,
:p9, :p10, :p11, :p12,
:p13, :p14, :p15, :p16,
:p17, :p18, :p19, :p20,
:p21, :p22, :p23, :p24,
:p25, :p26, :p27, :p28,
:p29, :p30, :p31, :p32,
:p33, :p34, :p35, :p36,
:p37, :p38, :p39, :p40,
:p41, :p42, :p43, :p44,
:p45, :p46, :p47, :p48, :p49))))
LLBLGen creates a sub query, but fetches ALL rows.
new LinqMetaData()
.Card
.Select(c => new
{
CardId = c.CardID,
Products = c.Products.Select(p => new { ProductId = p.ProductID })
})
.Take(50) //n
.Dump();
First query (generated by LLBLGen):
SELECT "LPLA_1"."CARDID" AS "CardId",
1 AS "LPFA_2",
"LPLA_1"."CARDID" AS "CardID"
FROM "CARD" "LPLA_1"
WHERE rownum <= 50
Second query fetches whole table (all rows!):
SELECT "LPLA_2"."PRODUCTID" AS "ProductId",
"LPLA_2"."CARDID" AS "CardID"
FROM "PRODUCT" "LPLA_2"