I have a SQL function that needs to be converted to C#. The SQL function uses the LIKE keyword and the wildcard '_'. How can I write the equivalent C# function? Here is the SQL function:
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