Note that there are some explanatory texts on larger screens.

plurals
  1. POc# linq query generates "ESCAPE '~'" syntax when translating "StartsWith" to sql "LIKE"
    primarykey
    data
    text
    <p>ora. i've got this linq syntax below that generates the sql below that. the sql server database that receives the query rejects the linq-appended "ESCAPE '~'". i'm still researching, but any perspective welcome!</p> <pre><code>var rc = ( from x in dc.Candidate join xs in dc.CandidateStatus on x.StatusId equals xs.CandidateStatusId join xss in dc.CandidateStatus on xs.SystemStatusId equals xss.CandidateStatusId where _active.Contains(xss.Code) &amp;&amp; (x.NickName.StartsWith(startsWith) || x.FirstName.StartsWith(startsWith)) orderby x.NickName, x.FirstName, x.LastName select new ListItem { Id = x.CandidateId, Label = FormatIndividual(x.LastName,x.FirstName,x.NickName) }); return rc.ToList&lt;ListItem&gt;(); SELECT [t0].[candid] AS [Id], [t0].[lastnm] AS [lastName], [t0].[firstnm] AS [firstName], [t0].[nicknm] AS [nickName] FROM [ats].[cand] AS [t0] INNER JOIN [ats].[candstatus] AS [t1] ON [t0].[statusid] = ([t1].[candstatusid]) INNER JOIN [ats].[candstatus] AS [t2] ON [t1].[sysstatid] = ([t2].[candstatusid]) WHERE ([t2].[code] IN (@p0, @p1, @p2)) AND (([t0].[nicknm] LIKE @p3 ESCAPE '~') OR ([t0].[firstnm] LIKE @p4 ESCAPE '~')) ORDER BY [t0].[nicknm], [t0].[firstnm], [t0].[lastnm] </code></pre> <p>implemented below. removed need for sql server wildcard ('%' - ie, what was being escaped).</p> <pre><code> ... //&amp;&amp; (x.NickName.StartsWith(startsWith) || x.FirstName.StartsWith(startsWith)) &amp;&amp; (x.NickName.Substring(0,1).Equals(startsWith) || x.FirstName.Substring(0,1).Equals(startsWith)) ... </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload