Accepted answer

you should be able to use a scalar sql function in your where criterias with codefirststorefunctions

assuming you want to map sql function [dbo].[latlongdistancecalc], and according to the test suite:

public class mydatacontext: dbcontext
    protected override void onmodelcreating(dbmodelbuilder modelbuilder)

       modelbuilder.conventions.add(new functionsconvention("dbo", this.gettype()));

    // "codefirstdatabaseschema" is a convention mandatory schema name
    // "latlongdistancecalc" is the name of your function

    [dbfunction("codefirstdatabaseschema", "latlongdistancecalc")]
    public static int latlongdistancecalc(int fromlat, int fromlong,
                                                       int tolat, int tolong)
       // no need to provide an implementation
       throw new notsupportedexception();

usage would then be:

       .where(e => mydatacontext.latlongdistancecalc(, e.long, lat, long) >= 10)

Related Query