0
你好请你能告诉我在最好的方式来实现LINQ过滤多个列VB.net LINQ上多列过滤
表:
CREATE TABLE [dbo].[user] (
[id] [int] IDENTITY(1,1) NOT NULL,
[firstName] [nvarchar](50) NULL,
[surname] [nvarchar](50) NULL,
[fullAddress] [nvarchar](1050) NULL
我通常使用SQL此
Dim firstname as string = 'bob'
Dim surname as String = 'holdness'
Dim address as String = 'blockbuster street'
Dim Stmquery as string = 'Select * from users '
if not String.isnullorEmpty(firstname) or not String.isnullorEmpty(surname) or not String.isnullorEmpty(address) then
Stmquery = Stmquery & "where"
end if
if not String.isnullorEmpty(firstname) then
Stmquery = Stmquery & " firstname = " & firstname
end if
if not String.isnullorEmpty(surname) then
Stmquery = Stmquery & " surname = " & surname
end if
if not String.isnullorEmpty(address) then
Stmquery = Stmquery & " address = " & address
end if
所以基本上如果字符串是空的,它会显示所有记录该列
有人能告诉我如何做到这一点的LINQ
感谢保罗
得益于它的工作就像一个梦要对数据库执行 – Easty 2013-03-26 14:16:54