kedro
kedro

Reputation: 1

EF 4.0 Inner join with ObjectQuery<Object>

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?

Upvotes: 0

Views: 2309

Answers (1)

Nix
Nix

Reputation: 58632

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
                   }
 );

Upvotes: 2

Related Questions