Is it possible to create anonymous type in LINQ extension methods in C#? -
is possible create anonymous type in linq extension methods in c#?
for example linq query.i.e.
var caquery = temp in catemp join casect in cadb.sectors on temp.sector_code equals casect.sector_code select new { //anonymous types cusip = temp.equity_cusip, compname = temp.company_name, exchange = temp.primary_exchange }; is same behavior supported linq extension methods in c#?
do mean "when using extension method syntax"? if so, absolutely. query exactly equivalent to:
var caquery = catemp.join(cadb.sectors, temp => temp.sector_code, casect => casect.sector_code, (temp, casect) => new { cusip = temp.equity_cusip, compname = temp.company_name, exchange = temp.primary_exchange }); the c# language specification sets out translations in section 7.16. note in case, join clause only followed select clause, projection performed within join call. otherwise (e.g. if had where clause) compiler have introduced transparent identifiers keep 2 range variables (temp , casect) available, via new anonymous type kept pair of them in single value.
every query expression expressible non-query-expression code. query expressions form of preprocessing.
Comments
Post a Comment