var result = from s1 in context.EMPLOYEE
where s1.NAME.IndexOf("Bill") == 0
=>上面的LINQ語法會產生以下SQL語法,滿少用到CHARINDEX
SELECT
[Extent1].[ID] AS [ID],
[Extent1].[NAME] AS [NAME]
FROM [dbo].[EMPLOYEE] AS [Extent1]
WHERE 0 = (( CAST(CHARINDEX(N'Bill', [Extent1].[NAME]) AS int)) - 1)
沒有留言:
張貼留言