public static class EdmxExtensions { [EdmFunction("YourEFModel", "String_Like")] public static Boolean Like(this String searchingIn, String lookingFor) { throw new Exception("Not implemented"); } }
Edmx >> Runtime >> ConceptualModels >> Schema <Function Name="String_Like" ReturnType="Edm.Boolean" > <Parameter Name="searchingIn" Type="Edm.String" /> <Parameter Name="lookingFor" Type="Edm.String" /> <DefiningExpression> searchingIn LIKE lookingFor </DefiningExpression> </Function>
以上方法 一:
db.Table.Where(s => DbFunctions.Like(s.FiledName, "%老五%")).ToList()
程序集 EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
命名空间 System.Data.Entity
以上方法二: