标签:style blog color io ar sp div c on
一、左连接查询
var query = people.GroupJoin(pets, person => person, pet => pet.Owner, (person, petCollection) => new { OwnerName = person.Name, Pet = PetCollection.Select( p => p.Name ) .DefaultIfEmpty() } ).ToList();
var query = (from person in context.People join pet in context.Pets on person equals pet.Owner into tempPets from pets in tempPets.DefaultIfEmpty() select new { OwnerName = person.Name, Pet = pets.Name }) .ToList();
EF selection expression 与 Linq备忘
标签:style blog color io ar sp div c on
原文地址:http://www.cnblogs.com/cxp9876/p/4002280.html