我有一个需要转换为 C# 的 SQL 函数。SQL 函数使用 LIKE 关键字和通配符“_”。如何编写等效的 C# 函数?下面是 SQL 函数:
Create Function [dbo].[fnGetWarehouseByGrade222]
(
@Grade nvarchar(2),
@Paste nvarchar(500)
)
Returns varchar(500)
As
Begin
declare @Return varchar(500)
if @Grade = '00' or @Grade = '01' or @Grade = '02' or @Grade = '03' or @Grade = '04'
begin
Select @Return = case when @Paste like 'D__G__DG' then '1GD'
when @Paste like 'D__G__DP' then '1GD'
when @Paste like 'D__G__D_' then '1GO'
when @Paste like 'N__G__D_' then '1GN'
when @Paste like 'D__G__H_' then '1GH'
when @Paste like 'N__G__H_' then '1GM'
when @Paste like 'G__G__H_' then '1GG' end
RETURN @Return
end
RETURN null
End