LINQ TO SQL 五表查询

目的实现:

var query = from P in db.Patrons
               join PAS in db.PatronAddresses on P.PatronNumber equals PAS.PatronNumber
               join PAT in db.PatronAudits on P.PatronNumber equals PAT.PatronNumber
               join PID in db.PatronIdentifications on P.PatronNumber equals PID.PatronNumber
               join PT in db.PatronTypes  on P.PatronTypeId equals PT.Id
               select new { P.PatronNumber,
                             P.PrimaryName_GivenName,
                             PAS.PostCode, PAT.AuditID,
                             PID.ExpiryDate, 
                             PT.PatronTypeName };
                if (null != query)
                {
                    foreach (var item in query)
                    {
                        //Console.WriteLine(item);
                    }
                }

 

posted @ 2012-11-22 09:58  璎Nicole珞  阅读(177)  评论(0编辑  收藏  举报