LINQ - Convertion - Asked By waseem kaleem on 30-Sep-11 04:46 AM

Can any one convert this expression "from c in dbo.Customer from c in c.Orders where c.city=="New York" select new{c,o}" to lambda expression
where orders is Entity
thanks....
Suchit shah replied to waseem kaleem on 30-Sep-11 05:28 AM
from c in dbo.Customer from c in c.Orders where c.city=="New York" select new{c,o}"

can u please clerify ur query first in ur query during select new {c,o} u right like this can u tell me frm where Object "O"
is coming there is no declarion of object O.. frm where u r getting the value of object O and what exactly u want tell me in detail so i can convert it in to Lamda
Suchit shah replied to waseem kaleem on 30-Sep-11 05:58 AM
"from c in dbo.Customer from c in c.Orders where c.city=="New York" select new{c,o}"

In your above query if i conside O as a Orders object then ur query would look like below query

dbo.Customer.SelectMany(C => Orders,(c,o) =>new{C = C,O = O})
.where(temp0 =>(temp0.C.City == "New Youk"))
.Select (temp0 => new { C = temp0.C, O = temp0.O})

if u need one more example 2 understand thn i give my example
my linq quey look like below :

from MB in M_Blocks

from MV in M_Villages

where MB.BlockName == "CHITRADURGA"

select new {MB,MV}


and its converted Lamda expression look like below

M_Blocks
.SelectMany (
MB => M_Villages,
(MB, MV) =>
new
{
MB = MB,
MV = MV
}
)
.Where (temp0 => (temp0.MB.BlockName == "CHITRADURGA"))
.Select (
temp0 =>
new
{
MB = temp0.MB,
MV = temp0.MV
}
)

waseem kaleem replied to Suchit shah on 30-Sep-11 12:33 PM
Thank you vey much.
Customer is parent table and Orders(EntitySet) is child table
I still have not executed your defined expression