sql - LIKEs and ORs and stuff in Linq -


I'm trying to use a linq-to-sql query || Which behaves equally in the same or SQL, like the likes / contains.

SQL:

  Select from user WHERE GroupNumber = 'A123456' or (first name like 'Bob%' and last name 'Like Smith')  

The result will be with everyone with the names "Bob Smith", along with everyone who has a group equivalent to A-123456. In my database, the SQL instance gives me three results (desired result):

 A 123456 John Davis A312345 Bob Smith A 123456 Matt Jones 

Linux: (PNUM = A 123456; "Bob"; final = "smith")

  var user = one to dc. Users where a.PolicyNumber == PNum || Order by (SqlMethods.Like (a.FirstName, first + "%") & amp; amp; SqlMethods.Like (a.LastName, Last + "%")) A. Select PolicyNumber, a.FirstName one;  

This will only give results on the left side of me:

 A 123456 John Davis A 123456 Matt Jones 

I have also tried. () And a.TartsWith (), but with each version I get the same two results. Whenever I remove any kind of / containers / starters, I get the desired result but I need a wildcard. How do I get all three results in the Linq query?

I definitely StartsWith in this case, just read the code To like C # - but this should work:

  var users = one to dc.Users where a.PolicyNumber == PNum || (A.FirstName.StartsWith (First) & amp; a.LastName.StartsWith (last)) by order a.PolicyNumber, a.FirstName Select one;  

If that query does not work, can you post SQL generated by it? Just set the log of reference to write the console, or whatever is simple (I'll just write a console app to test this problem - it will be easier to run the UI every time.)


Comments