Function Mapping treated as In Memory

Posts   
 
    
matthewma
User
Posts: 36
Joined: 24-May-2013
# Posted on: 14-Jan-2016 20:44:50   

Recently I encountered a situation similar to https://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=16966

What I did is explicitly passing in a no use property of the entity to trick it(linq expression parser?) not to treat the function as in memory

Some code snippet of mine:

public static Object GeomFromGeojson(string geojson, Object o[This is My Trick]) { return null; }

this.Add(new FunctionMapping(typeof(GeomFuncs), "GeomFromGeojson", 2, "ST_GeomFromGeoJSON({0})", "", ""));

linqMetaData.SomeEntity.Where(c => GeomFuncs.STContains(c.Area, GeomFuncs.GeomFromGeojson("{\"type\":\"Point\",\"coordinates\":[-87.22217, 30.44195]}", c.Id[This is My Trick])))

Without the tricking second parameter, the whole GeomFromGeojson will be passed in as null, which is result of the function definition, resulting unexpected result.

So, my question is, except this workaround of mine, is there a better way to make it work?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 15-Jan-2016 12:53:39   

That's the workaround, available. The logic looks for a dependency to decide whether it would be executed in-memory or mapped to a db function.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 15-Jan-2016 13:13:36   

Indeed, what Walaa says: if it can't determine some DB related element is involved it will assume in-memory code and will run it as in-memory, as in Linq queries you can mix both.

Frans Bouma | Lead developer LLBLGen Pro
matthewma
User
Posts: 36
Joined: 24-May-2013
# Posted on: 15-Jan-2016 17:09:40   

Got it. Thank you. You guys are helpful as always.