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