1

ref: How to create like '234%4' or %2324%335% in EntityFramework

Does the solution using [EdmFunction] work for esql + EF4.3 code-first (where there is no .edmx file) by simply implementing the function? then would it be available in esql, ie: "it.UserName.Like('_user%')" ?

Community
  • 1
  • 1
diegohb
  • 1,857
  • 2
  • 16
  • 34

2 Answers2

2

No. EdmFunction attribute and its functionality is currently dependent on EDMX mapping file.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Thanks a lot.. i wonder if there's any other equivalent functionality with code-first approach.. `[System.Data.Objects.DataClasses.EdmFunction( "Your.Namespace", "String_Like")]public static Boolean Like(this String searchingIn, String lookingFor) { throw new Exception("Not implemented"); }` maybe this is the function that query builder calls onto so if i implement it instead of throwing the exception ... ? – diegohb Mar 04 '12 at 07:40
  • No. There is no equivalent. The function is only stub for SQL function mapped in EDMX file. Implementing it will not help you. – Ladislav Mrnka Mar 04 '12 at 08:48
0

Then, as now, you can use .StartsWith or .Contains which map to LIKE:

it.UserName.StartsWith("_user")

will translate to

UserName LIKE '_user%'

(and secretly apply your case insensitive collations and such, causing Contains to deviate from an accurate mapping to the local functionality.)

Scott Stafford
  • 43,764
  • 28
  • 129
  • 177