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

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept