我在 Microsoft Dynamics CRM 2011 中有一个情况,这里我有一组帐户,其中包含与 permitCounty 相关的 Permit 和 permit ae,并且 permitCounty 与 County
我想得到像这个查询这样的输出。
但这不合适
strSearch="Some text";
var lstItems = (from county in x.De_countySet
join permitcounty in x.de_permitcountySet on county.De_countyId equals permitcounty.de_CountyId.Id
join permit in x.de_permitSet on permitcounty.de_PermitId.Id equals permit.de_permitId
join account in x.AccountSet on permit.de_AccountId.Id equals account.AccountId into outer
where permit.de_Type.Equals("Type1") && permit.statuscode.Equals("Active") // Permit Type as Type1 and Status as Active
where account.De_LegalName.Contains(strSearch) || account.Name.Contains(strSearch) // Search in Legal Name and Account full name
where county.de_CountyName.Contains(strSearch) // Search in County Name
orderby county.de_CountyName
from account in outer.DefaultIfEmpty()
select new clsTemp
{
Name = account.Name,
De_LegalName = account.De_LegalName,
Address1_Line1 = account.Address1_Line1,
Address1_City = account.Address1_City,
Address1_PostalCode = account.Address1_PostalCode,
de_CountyName = county.de_CountyName
}).ToList();
任何帮助表示赞赏。
维努