Reuse expression in EF6 select statement

Is possible replace custom expression by a method in EF6 without using AsEnumerable()?

This is a very simple expression that EF6 can handle/convert to sql and run at db server:

db.Foo.Select(f => new { ScreenName = !String.IsNullOrWhiteSpace(f.nickname) ? f.nickname : f.name });

Make it reusable somehow is desired:

db.Foo.Select(f => new { ScreenName = MySqlFunctions.GetExibitionName(f.name, f.nickname));

I'm aware that SqlFunctions has a lot of predefined methods like that, but I'm wondering how to write my own in order to make a translation between .Net and Sql.



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)