orderby by lamda expression does not work?

Posts   
 
    
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 07-May-2010 12:08:34   

I want to sort IP-Address information by the last number. The IP-Address is stored as a nvarchar in the database.

I´ve tried the following:

Func<string, int> Host = s => Int32.Parse(s.Split('.')[3]);
var q = from c in meta.Terminal orderby Host(c.Ipaddr) select c;

EntityCollection<TerminalEntity> terminals = ((ILLBLGenProQuery)q).Execute<EntityCollection<TerminalEntity>>();

the orderby doesn´t work confused

Any suggestions?

Kind regards, Carlo

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-May-2010 02:36:23   

That func is a 'delegate' at runtime, so isn't convertable to sql. To do what you want please try FunctionMappings.

David Elizondo | LLBLGen Support Team
Rushmore
User
Posts: 125
Joined: 27-Jan-2005
# Posted on: 10-May-2010 14:09:49   

daelmo wrote:

That func is a 'delegate' at runtime, so isn't convertable to sql. To do what you want please try FunctionMappings.

Thank you, I will give it a try.

My workaround for now is to sort the result:


Func<string, int> Host = s => Int32.Parse(s.Split('.')[3]);
var terminals = from c in Terminal.GetTerminals() orderby Host(c.Ipaddr) select c; 

Terminal.GetTerminals() returns EntityCollection<TerminalEntity>().

Kind regards, Carlo