views:

21

answers:

1

I cant find any samples how to write Inner join with ObjectQuery using Entity SQL in EF 4.0 May be some on may help?

A: 

Here is an example, but if might be more useful if you tell us what you are trying to accomplish.

Example(assume people and pets are LINQ to SQL classes):

public class People{
     public int ID;
     public int Name;
}
public class Pets{
    public int ID;
    public int Name;
    public int Owner;

 }


ObjectQuery<People> people = null;
ObjectQuery<Pets> pets = null;   

var query = people.Join(pets,
               person => person.ID,
               pet => pet.Owner,
               (person, pet) =>
                   new { 
                        OwnerName = person.Name,
                        Pet = pet.Name
                   }
 );
Nix