Walaa wrote:
LIKE expects a constant (string pattern), not a field value.
Oh dear. I use things in SQL alot like that:
... WHERE @emailAddress LIKE '%' + [EmailDomain]
How about a Replace? This seems to work:
public IQueryable<DomainNameEntity> ValidateUser(string clientUrl, string emailAddress)
{
var domainNameEntities = from a in metaData.DomainName
where a.Client.ClientName == clientUrl &&
emailAddress.Replace(a.EmailDomain,String.Empty) != emailAddress
select a;
return domainNameEntities;
}
and produces this SQL:
Query: SELECT TOP 1 COUNT(*) AS [LPAV_] FROM ( [dbo].[CLIENT] [LPA_L1] INNER JOIN [dbo].[DomainName] [LPA_L2] ON [LPA_L1].[IDClient]=[LPA_L2].[IDClient]) WHERE ( ( ( ( ( [LPA_L1].[ClientName] = @ClientName1) AND ( REPLACE(@LO344820423, [LPA_L2].[EmailDomain], @LO2d2816fe4) <> @LPFA_12)))))
Parameter: @ClientName1 : AnsiString. Length: 50. Precision: 0. Scale: 0. Direction: Input. Value: "Demo".
Parameter: @LO344820423 : String. Length: 16. Precision: 0. Scale: 0. Direction: Input. Value: "anyone@valid.com".
Parameter: @LO2d2816fe4 : String. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: "".
Parameter: @LPFA_12 : String. Length: 16. Precision: 0. Scale: 0. Direction: Input. Value: "anyone@valid.com".
I'll use that unless you see any potential dangers with it. I can't