I'd like to wrap the SqlFunctions.IsNumeric function so that I can use it in other layer without the need to add reference to System.Data (no matter why).
Here is what I did -
In my Repository Interfaces:
public interface IUtils
{
Expression<Func<bool>> IsNumeric(string str);
}
In my ef layer:
public class EFUtils : IUtils
{
public Expression<Func<bool>> IsNumeric(string str)
{
return () => SqlFunctions.IsNumeric(str) == 1;
}
}
In my business later:
public class RepositoryUtils
{
protected static IUtils Utils { get; set; }
static RepositoryUtils()
{
Utils = ObjectFactory.GetInstance<IUtils>(); //Using structureMap
}
public static Expression<Func< bool>> IsNumeric(string str)
{
return Utils.IsNumeric(str);
}
}
The problem is that now, after I exposed the method, I don't really know how to use it..
It is something like:
Customers.OrderBy(x=>**Order by is numeric on x.Name);
Any idea?