{"id":346,"date":"2020-01-26T15:37:00","date_gmt":"2020-01-26T02:37:00","guid":{"rendered":"http:\/\/blog.wiseowls.co.nz\/?p=346"},"modified":"2026-03-08T00:44:41","modified_gmt":"2026-03-07T11:44:41","slug":"custom-functions-ef-core-3","status":"publish","type":"post","link":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/","title":{"rendered":"Entity Framework Core 3 &#8211; Custom Functions (Using IMethodCallTranslator)"},"content":{"rendered":"\n<p>Every now and then Stack Overflow provides fantastic opportunities to learn something new. One user asked whether SQL Server&#8217;s DECRYPTBYPASSPHRASE can be implemented with Entity Framework Core 2.2 so they can fetch encrypted strings in SQL.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">We like the challenge<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.thinktecture.com\/en\/entity-framework\/entity-framework-core-custom-functions-using-imethodcalltranslator\/\">This post<\/a> led us to quickly implement a PoC for EF2.2. We&#8217;ve got a Model defined like so:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">public partial class Model\n{\n    public int Id { get; set; }\n    public byte[] Encrypted { get; set; } \/\/ apparently encrypted data is stored in `VARBINARY`, which translates to `byte[]`, so I had to tweak it here\n    [NotMapped] \/\/ this is still required as EF will not know where to get the data unless we tell it (see down below)\n    public string Decrypted { get; set; } \/\/ the whole goal of this exercise here\n    public Table2 Table2 { get; set; }\n}<\/code><\/pre>\n\n\n\n<p>And a <code>Concrete Repository<\/code>&nbsp;to access the DB:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">public IEnumerable&lt;Model> GetAllById(int id)\n{\n    \/\/ you will need to uncomment the following line to work with your key\n    \/\/_dbContext.Database.ExecuteSqlCommand(\"OPEN SYMMETRIC KEY {1} DECRYPTION BY PASSWORD = '{2}';\", SymmetricKeyName, SymmetricKeyPassword);\n    var filteredSet = Set.Include(x => x.Table2)\n        .Where(x => x.Id == id)\n        .Where(x => x.Table2.IsSomething)\n        .Select(m => new Model\n    {\n        Id = m.Id,\n        \/\/Decrypted = EF.Functions.DecryptByKey(m.Encrypted), \/\/ since the key's opened for session scope - just relying on it should do the trick\n        Decrypted = EF.Functions.Decrypt(\"test\", m.Encrypted),\n        Table2 = m.Table2,\n        Encrypted = m.Encrypted\n    }).ToList();\n    \/\/ you will need to uncomment the following line to work with your key\n    \/\/_dbContext.Database.ExecuteSqlCommand(\"CLOSE SYMMETRIC KEY {1};\", SymmetricKeyName);\n    return filteredSet;\n}<\/code><\/pre>\n\n\n\n<p>now, defining&nbsp;<code>EF.Functions.Decrypt<\/code>&nbsp;is the key here. We basically have to do it twice: <\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>as extension methods so we can use then in LINQ and <\/li><li>as EF Expression tree nodes. <\/li><\/ol>\n\n\n\n<p>What EF then does, for each method call it discovers, it checks internal list of&nbsp;<code>IMethodCallTranslator<\/code>&nbsp;and if it discovers a match &#8211; it defers the function to SQL. Otherwise it will have to be run in C#. So all the plumbing we&#8217;re going to have to do next is basically needed to inject&nbsp;<code>TranslateImpl<\/code>&nbsp;into that list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The <code>IMethodCallTranslator<\/code> itself<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">public class TranslateImpl : IMethodCallTranslator\n{\n\n    private static readonly MethodInfo _encryptMethod\n        = typeof(DbFunctionsExtensions).GetMethod(\n            nameof(DbFunctionsExtensions.Encrypt),\n            new[] { typeof(DbFunctions), typeof(string), typeof(string) });\n    private static readonly MethodInfo _decryptMethod\n        = typeof(DbFunctionsExtensions).GetMethod(\n            nameof(DbFunctionsExtensions.Decrypt),\n            new[] { typeof(DbFunctions), typeof(string), typeof(byte[]) });\n\n    private static readonly MethodInfo _decryptByKeyMethod\n        = typeof(DbFunctionsExtensions).GetMethod(\n            nameof(DbFunctionsExtensions.DecryptByKey),\n            new[] { typeof(DbFunctions), typeof(byte[]) });\n\n    public Expression Translate(MethodCallExpression methodCallExpression)\n    {\n        if (methodCallExpression.Method == _encryptMethod)\n        {\n            var password = methodCallExpression.Arguments[1];\n            var value = methodCallExpression.Arguments[2];\n            return new EncryptExpression(password, value);\n        }\n        if (methodCallExpression.Method == _decryptMethod)\n        {\n            var password = methodCallExpression.Arguments[1];\n            var value = methodCallExpression.Arguments[2];\n            return new DecryptExpression(password, value);\n        }\n\n        if (methodCallExpression.Method == _decryptByKeyMethod)\n        {\n            var value = methodCallExpression.Arguments[1];\n            return new DecryptByKeyExpression(value);\n        }\n\n        return null;\n    }\n}<\/code><\/pre>\n\n\n\n<p>I ended up implementing three expression stubs: &nbsp;<code>DecryptByKey<\/code>,&nbsp;<code>DecryptByPassphrase<\/code>&nbsp;and&nbsp;<code>EncryptByPassphrase<\/code>, for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">public class DecryptByKeyExpression : Expression\n{\n    private readonly Expression _value;\n\n    public override ExpressionType NodeType => ExpressionType.Extension;\n    public override Type Type => typeof(string);\n    public override bool CanReduce => false;\n\n    protected override Expression VisitChildren(ExpressionVisitor visitor)\n    {\n        var visitedValue = visitor.Visit(_value);\n\n        if (ReferenceEquals(_value, visitedValue))\n        {\n            return this;\n        }\n\n        return new DecryptByKeyExpression(visitedValue);\n    }\n\n    protected override Expression Accept(ExpressionVisitor visitor)\n    {\n        if (!(visitor is IQuerySqlGenerator))\n        {\n            return base.Accept(visitor);\n        }\n        visitor.Visit(new SqlFragmentExpression(\"CONVERT(VARCHAR(MAX), DECRYPTBYKEY(\"));\n        visitor.Visit(_value);\n        visitor.Visit(new SqlFragmentExpression(\"))\"));\n        return this;\n    }\n\n    public DecryptByKeyExpression(Expression value)\n    {\n        _value = value;\n    }\n}<\/code><\/pre>\n\n\n\n<p>All in all, it ends up being a pretty trivial string building exercise after all. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">But the question remained <\/h2>\n\n\n\n<p>Can we port it forward? When we tried applying the same code base to version 3 of the framework we found that code has changed quite a bit. For one, Expressions were no longer  an option.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Good news<\/h2>\n\n\n\n<p>Good news was that the approach was still valid. Custom Method Call translation  is still a thing in EF Core 3. Even better news,  the functionality seems to have gotten a bit more polished in the new version and now it&#8217;s a bit easier to do.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution<\/h2>\n\n\n\n<p>In EF Core 3, we&#8217;ve got to deal with  <code>ISqlExpressionFactory<\/code> to get most of the job done. It gets passed around to plugins and has convenient methods to generate required expressions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"csharp\" class=\"language-csharp\">public class TranslateImpl : IMethodCallTranslator\n    {\n        private readonly ISqlExpressionFactory _expressionFactory;\n\n        private static readonly MethodInfo _encryptMethod\n            = typeof(DbFunctionsExtensions).GetMethod(\n                nameof(DbFunctionsExtensions.Encrypt),\n                new[] { typeof(DbFunctions), typeof(string), typeof(string) });\n        private static readonly MethodInfo _decryptMethod\n            = typeof(DbFunctionsExtensions).GetMethod(\n                nameof(DbFunctionsExtensions.Decrypt),\n                new[] { typeof(DbFunctions), typeof(string), typeof(byte[]) });\n\n        private static readonly MethodInfo _decryptByKeyMethod\n            = typeof(DbFunctionsExtensions).GetMethod(\n                nameof(DbFunctionsExtensions.DecryptByKey),\n                new[] { typeof(DbFunctions), typeof(byte[]) });\n\n        public TranslateImpl(ISqlExpressionFactory expressionFactory)\n        {\n            _expressionFactory = expressionFactory;\n        }\n\n        public SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList&lt;SqlExpression> arguments)\n        {\n            var args = new List&lt;SqlExpression> { arguments[1], arguments[2] }; \/\/ cut the first parameter from extension function\n            if (method == _encryptMethod)\n            {\n                return _expressionFactory.Function(instance, \"EncryptByPassPhrase\", args, typeof(byte[]));\n            }\n            if (method == _decryptMethod)\n            {\n                return _expressionFactory.Function(instance, \"DecryptByPassPhrase\", args, typeof(byte[]));\n            }\n\n            if (method == _decryptByKeyMethod)\n            {\n                return _expressionFactory.Function(instance, \"DecryptByKey\", args, typeof(byte[]));\n            }\n\n            return null;\n        }\n    }<\/code><\/pre>\n\n\n\n<p>this is way easier than the previous version! <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Talk is cheap. Show me the code<\/h2>\n\n\n\n<p>Working code can be <a href=\"https:\/\/github.com\/tkhadimullin\/ef-core-custom-functions\/tree\/feature\/ef-3.1-version\">found on my GitHub<\/a>, check out the <a href=\"https:\/\/github.com\/tkhadimullin\/ef-core-custom-functions\/compare\/feature\/ef-3.1-version\">difference<\/a> between implementations for both frameworks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every now and then Stack Overflow provides fantastic opportunities to learn something new. One user asked whether SQL Server&#8217;s DECRYPTBYPASSPHRASE can be implemented with Entity Framework Core 2.2 so they can fetch encrypted strings in SQL.<\/p>\n","protected":false},"author":1,"featured_media":353,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[11],"tags":[12,23,59],"class_list":["post-346","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev","tag-c","tag-ef-core","tag-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Entity Framework Core 3 - Custom Functions (Using IMethodCallTranslator) - Timur and associates<\/title>\n<meta name=\"description\" content=\"Plugging custom SQL functions into EF Core 3 pipeline using IMethodCallTranslator. We make DECRYPTBYPASSPHRASE work with LINQ.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Entity Framework Core 3 - Custom Functions (Using IMethodCallTranslator) - Timur and associates\" \/>\n<meta property=\"og:description\" content=\"Plugging custom SQL functions into EF Core 3 pipeline using IMethodCallTranslator. We make DECRYPTBYPASSPHRASE work with LINQ.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/\" \/>\n<meta property=\"og:site_name\" content=\"Timur and associates\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-26T02:37:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-07T11:44:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2021\/01\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1919\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"timur\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@TimurKh\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/\"},\"author\":{\"name\":\"timur\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#\\\/schema\\\/person\\\/34d0ed30d573b5bc317ea990bd2e0c59\"},\"headline\":\"Entity Framework Core 3 &#8211; Custom Functions (Using IMethodCallTranslator)\",\"datePublished\":\"2020-01-26T02:37:00+00:00\",\"dateModified\":\"2026-03-07T11:44:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/\"},\"wordCount\":342,\"image\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg\",\"keywords\":[\"c#\",\"ef-core\",\"sql\"],\"articleSection\":[\"Development\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/\",\"url\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/\",\"name\":\"Entity Framework Core 3 - Custom Functions (Using IMethodCallTranslator) - Timur and associates\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg\",\"datePublished\":\"2020-01-26T02:37:00+00:00\",\"dateModified\":\"2026-03-07T11:44:41+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#\\\/schema\\\/person\\\/34d0ed30d573b5bc317ea990bd2e0c59\"},\"description\":\"Plugging custom SQL functions into EF Core 3 pipeline using IMethodCallTranslator. We make DECRYPTBYPASSPHRASE work with LINQ.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/#primaryimage\",\"url\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg\",\"contentUrl\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/wp-content\\\/uploads\\\/2021\\\/01\\\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg\",\"width\":2560,\"height\":1919,\"caption\":\"Photo by Kevin Ku on Unsplash\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/index.php\\\/2020\\\/01\\\/26\\\/custom-functions-ef-core-3\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Entity Framework Core 3 &#8211; Custom Functions (Using IMethodCallTranslator)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#website\",\"url\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/\",\"name\":\"Timur and associates\",\"description\":\"Notes of an IT contractor\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blog.wiseowls.co.nz\\\/#\\\/schema\\\/person\\\/34d0ed30d573b5bc317ea990bd2e0c59\",\"name\":\"timur\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg\",\"caption\":\"timur\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/TimurKh\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Entity Framework Core 3 - Custom Functions (Using IMethodCallTranslator) - Timur and associates","description":"Plugging custom SQL functions into EF Core 3 pipeline using IMethodCallTranslator. We make DECRYPTBYPASSPHRASE work with LINQ.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/","og_locale":"en_US","og_type":"article","og_title":"Entity Framework Core 3 - Custom Functions (Using IMethodCallTranslator) - Timur and associates","og_description":"Plugging custom SQL functions into EF Core 3 pipeline using IMethodCallTranslator. We make DECRYPTBYPASSPHRASE work with LINQ.","og_url":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/","og_site_name":"Timur and associates","article_published_time":"2020-01-26T02:37:00+00:00","article_modified_time":"2026-03-07T11:44:41+00:00","og_image":[{"width":2560,"height":1919,"url":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2021\/01\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg","type":"image\/jpeg"}],"author":"timur","twitter_card":"summary_large_image","twitter_creator":"@TimurKh","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/#article","isPartOf":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/"},"author":{"name":"timur","@id":"https:\/\/blog.wiseowls.co.nz\/#\/schema\/person\/34d0ed30d573b5bc317ea990bd2e0c59"},"headline":"Entity Framework Core 3 &#8211; Custom Functions (Using IMethodCallTranslator)","datePublished":"2020-01-26T02:37:00+00:00","dateModified":"2026-03-07T11:44:41+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/"},"wordCount":342,"image":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2021\/01\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg","keywords":["c#","ef-core","sql"],"articleSection":["Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/","url":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/","name":"Entity Framework Core 3 - Custom Functions (Using IMethodCallTranslator) - Timur and associates","isPartOf":{"@id":"https:\/\/blog.wiseowls.co.nz\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/#primaryimage"},"image":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2021\/01\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg","datePublished":"2020-01-26T02:37:00+00:00","dateModified":"2026-03-07T11:44:41+00:00","author":{"@id":"https:\/\/blog.wiseowls.co.nz\/#\/schema\/person\/34d0ed30d573b5bc317ea990bd2e0c59"},"description":"Plugging custom SQL functions into EF Core 3 pipeline using IMethodCallTranslator. We make DECRYPTBYPASSPHRASE work with LINQ.","breadcrumb":{"@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/#primaryimage","url":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2021\/01\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg","contentUrl":"https:\/\/blog.wiseowls.co.nz\/wp-content\/uploads\/2021\/01\/kevin-ku-w7ZyuGYNpRQ-unsplash-scaled.jpg","width":2560,"height":1919,"caption":"Photo by Kevin Ku on Unsplash"},{"@type":"BreadcrumbList","@id":"https:\/\/blog.wiseowls.co.nz\/index.php\/2020\/01\/26\/custom-functions-ef-core-3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.wiseowls.co.nz\/"},{"@type":"ListItem","position":2,"name":"Entity Framework Core 3 &#8211; Custom Functions (Using IMethodCallTranslator)"}]},{"@type":"WebSite","@id":"https:\/\/blog.wiseowls.co.nz\/#website","url":"https:\/\/blog.wiseowls.co.nz\/","name":"Timur and associates","description":"Notes of an IT contractor","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.wiseowls.co.nz\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.wiseowls.co.nz\/#\/schema\/person\/34d0ed30d573b5bc317ea990bd2e0c59","name":"timur","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/23d55e17d4f0990ee4d12bc6e5dcfb58a292934efd62a185756876379e780b16?s=96&r=pg","caption":"timur"},"sameAs":["https:\/\/x.com\/TimurKh"]}]}},"_links":{"self":[{"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/posts\/346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/comments?post=346"}],"version-history":[{"count":7,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/posts\/346\/revisions"}],"predecessor-version":[{"id":404,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/posts\/346\/revisions\/404"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/media\/353"}],"wp:attachment":[{"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/media?parent=346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/categories?post=346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.wiseowls.co.nz\/index.php\/wp-json\/wp\/v2\/tags?post=346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}