Windows10 Windows10 - 1 year ago 74
C# Question

Always Encrypted column - LINQ query Equals not working

I have encrypted SSN column using Always Encrypted feature in SQL server 2016. When I try to get the encrypted column in LINQ I always get error. I tried equals and contains but got the same error.

Query = Query.Where(t => t.SSN == InputSSN);

The data types char(9) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256',..are incompatible in the equal to operator.
Statement(s) could not be prepared.

SSN,InputSSN - string
in DB - SSN CHar(9) Latin1_General_BIN2

Answer Source

have changed the datatype in table and it worked.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download