Home

Disregarded where clause in CRMLinqPad

Losing sanity on this. Selecting Contract Lines by State does not work as expected.

Running this:

var lines = (from contline in ContractDetailSet
join cont in ContractSet
on contline.ContractId.Id equals cont.Id

where cont.StateCode.Equals(ContractState.Draft)

where contline.ExpiresOn > new DateTime(2016,5,01)
&& contline.ExpiresOn < new DateTime(2016,5,16)


select new { Title = contline.Title,
LineState = contline.StateCode,
ContExp = cont.ExpiresOn,
ContState = cont.StateCode,
active = ContractState.Active,
draft = ContractState.Draft,
cancekled = ContractState.Canceled,
matchActive = (cont.StateCode.Equals(ContractState.Active)),
matcDraft = (cont.StateCode.Equals(ContractState.Draft)),
matchCanc = (cont.StateCode.Equals(ContractState.Canceled))

}
);
lines.Dump();

I get many lines that are not ContractState.Draft -- I put all those elements in the anonymous class to see what is up, and ll of those behave as expected. What is not working is the line:

where cont.StateCode.Equals(ContractState.Draft)

If I use ContractState.Active or ContractState.Canceled I get zero lines. If I use Draft I get several, but it includes Active lines.

Pasting this into Visual Studio it filters as expected. I tried recompiling the entities (though they all look right in the output)

???
Sign In or Register to comment.