c# - Execute decrypt function on LINQ query -


if have following query companies.name encrypted:

obviously executing following query going invalid because we're searching against encrypted names.

iqueryable<file> files = getfiles(f => f.clients.any(fc => fc.contacts.any(c => c.companies.any(x => x.name.contains(searchtext))))); 

i'm after way decrypt companies.name before query executed via decrypt() function have in place.

edit 1:

i have partial class company decrypted property called displayname returns decrypted name property, linq telling me specified type member displayname not supported in linq entities. initializers, entity members, , entity navigation properties supported.

iqueryable<file> files = getfiles(f => f.clients.any(fc => fc.contacts.any(c => c.companies.any(x => x.displayname.contains(searchtext))))); 

if there's way use partial class property inside linq statement guess work.

edit 2:

i ended creating sql clr function decrypts company names , can call datacontext.searchcompanies(searchtext) in code return list of companies.

i'm not sure however, how replace companies within original list?

you define stored procedure perform search:

create procedure searchcompanies @searchtext nvarchar(100) begin     select * companies c  -- implement logic here...     dbo.decrypt(c.name) @searchtext end 

then, add stored procedure function import data context , data:

using(var datacontext = new datacontext()) {     return datacontext.searchcompanies(searchtext); } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -