パラメータで true であるプロパティの 1 つがレコードで true であるという条件で、Linq を使用してエンティティのすべてのレコードを取得しようとしています。
私は論理的な「または」を達成しようとしています。コードを見てください。
FetchXML では動作しています:
public void GetLock(bool account = false, bool contact = false, bool incident = false)
{
var fetch = @"
<fetch mapping='logical'>
<entity name='de_processimport'>
<attribute name='de_processimportid' />
<filter type='or'>";
if (account)
fetch += @"<condition attribute='de_processingaccount' operator='eq' value='true' />";
if (contact)
fetch += @"<condition attribute='de_processingcontact' operator='eq' value='true' />";
if (incident)
fetch += @"<condition attribute='de_processingincident' operator='eq' value='true' />";
fetch += @"
</filter>
</entity>
</fetch>";
var processing = service.RetrieveMultiple(new FetchExpression(fetch));
...
}
Linq では動作していません:
public void GetLock(bool account = false, bool contact = false, bool incident = false)
{
var processing = linq.de_processimportSet
.Where(p => // get records that are processing the entities we are processing
(account) ? p.de_ProcessingAccount == true : false // get processImport records where processingAccount is true or otherwise ignore this clause (false)
|| (contact) ? p.de_ProcessingContact == true : false
|| (incident) ? p.de_ProcessingIncident == true : false
);
...
}