During this time, writing of LINQ and SQL is missing! Or are you getting old? More and more will not change
Problem:
========================================================== ========
VaR ret = from X in LS
Where (
String. isnullorempty (Arg. querytext )? True:
(
(X. ?? ""). Toupper (). Contains (Arg. querytext. toupper ())
| (X. B ?? ""). Toupper (). Contains (Arg. querytext. toupper ())
| (X. c ?? ""). Toupper (). Contains (Arg. querytext. toupper ())
)
I can see this statement to understand its meaning, but I have no choice but to look forward to the answer.
========================================================== ========
The premise for this question is that this statement is a query performed in LINQ to object and cannot directly generate an SQL statement. I stared at this and did not find it for a night, I want to convert it into an SQL statement, but I find that I have regressed to a certain extent, and I do not know how to manually convert it. I ran to csdn to ask for help, but found that everyone had been to May 1.
Today, when I went out to play with my niece, I suddenly thought why I didn't switch to LINQ to SQL for testing. Both vs2010 and third-party software can be automatically converted to SQL statements, come back and implement it quickly. The result is as follows:
Select * from LS
Where
Upper (a) Like querytext or
Upper (B) Like querytext or
Upper (c) Like querytext
That's simple.
Note ):
String [] YY = new string [] {"test "};
VaR ret = from X in LS
Where (
String. isnullorempty (Arg. querytext )? True:
(
(X. ?? ""). Toupper (). Contains (Arg. querytext. toupper ())
| (X. B ?? ""). Toupper (). Contains (Arg. querytext. toupper ())
| (X. c ?? ""). Toupper (). Contains (Arg. querytext. toupper ())
& Yy. Contains (X. d)
)
The SQL statement is as follows:
Select * from LS
Where
Upper (a) Like querytext or
Upper (B) Like querytext or
Upper (c) Like querytext and
D In (@ P1)
Another little fat cat, haha: