日期:2014-05-20  浏览次数:20691 次

LINQ条件查询语句.
VB code
    
Dim a As String = someVlaue                    
Dim b As String = someVlaue            
Dim sql As String = "select * from table1 where column1 = 1"

If a <> "" Then

sql = sql + " and columnA = '" + a + "'"

End If

If b <> "" Then

sql = sql + " and columnB = '" + b + "'"

 End If



请问如何将以上代码转换为LINQ。 最好用VB.NET。 谢谢!

------解决方案--------------------
参考
------解决方案--------------------
var v=able1.Where(a=>a.column1==1);
没看到if,简单的做法
If a <> "" Then
v.Where(a=>a. columnA =="a");
End If

If b <> "" Then

v.Where(a=>a. columnB =="b");

 End If