CRM2011 linq 查询

  
    
// *****************************************************************************************************************
// LNQ Retrieving related entity columns (for 1 to N relationships)
// *****************************************************************************************************************

System.Console.WriteLine();
System.Console.WriteLine(
" List of Contact and Account Info by retrieving related entity columns " );
System.Console.WriteLine(
" ====================================== " );

var query_retrieve1
= from c in context.ContactSet
join a
in context.AccountSet on c.ContactId equals a.PrimaryContactId.Id
where c.ContactId != _contactid2
select
new { Contact = c, Account = a };

foreach (var c in query_retrieve1)
{
System.Console.WriteLine(
" Acct: " + c.Account.Name + " \t\t " + " Contact: " + c.Contact.FullName);
}

System.Console.WriteLine(
" ===================================== " );
System.Console.WriteLine();

你可能感兴趣的:(LINQ)