var results = from formNumber in context.DetailTM
join c in context.ClaimPeriodTM on formNumber.ClaimPeriod equals c.Cid
w开发者_StackOverflowhere formNumber.FormNumber.StartsWith(fNumber)
&& formNumber.RegistrationNumber != registrationNumber
select new { RegNo = formNumber.RegistrationNumber,
CP = c.ClaimPeriod, FormNo = formNumber.FormNumber };
The AND CLAUSE with .StartsWith
Doesn't work. If I use == operator the query works fine. I tried adding brackets to the where clause but it didn't help. Any idea what is missing. Thank you in Advance.
Try something very basic like "&& true == false" and see if that fails. Also reverse the order. If you reverse the order, is it still the second clause that fails?
There's nothing about StartsWith that should cause this behavior. There's something else going on here. Trim and move elements until you isolate the real bug.
What is the database type for FormNumber? If its char (and not varchar), then you may have to trim one or both sides of the comparison.
where
formNumber.FormNumber.Trim().StartsWith(fNumber.Trim())
&& formNumber.RegistrationNumber != registrationNumber
Same as jrummells answer, just targetted by the additional comments.
formNumber.RegistrationNumber != registrationNumber
Check the database types here. If they are fixed length (char or nchar), you may need to do some trimming.
精彩评论