Linq to Python

sturlamolden sturlamolden at yahoo.no
Thu Sep 25 12:34:12 CEST 2008


On 25 Sep, 12:06, hrishy <hris... at yahoo.co.uk> wrote:

> var stoogeGuys =
>      Beginning with the XML source
>      from xmlGuys in xmlSource.Descendants("Stooge")
>      Join to the array on the common element "stoogeName"
>      join arrayGuys in familyFacts
>            on xmlGuys.Element("stoogeName").Value equals arrayGuys.stoogeName
>      Join to the database on the common element "stoogeName"
>      join dbGuys in stoogeContext.stoogeTables
>            on xmlGuys.Element("stoogeName").Value equals dbGuys.stoogeName
>      select new
>      {
>         firstName    = dbGuys.stoogeName,
>         familyName   = arrayGuys.familyName,
>         birthDate    = xmlGuys.Element("birthDate").Value,
>         deathDate    = xmlGuys.Element("deathDate").Value,
>         hairCutStyle = dbGuys.stoogeHaircut,
>      };
> [/code]


That is a for loop over xmlGuys in xmlSource.Descendants("Stooge").
Those joins are e.g. dictionary lookups, and finally an object with
names, birthdates, etc. are appended to the list stoogeGuys.









More information about the Python-list mailing list