New Posts New Posts RSS Feed: ToString() lambda expression
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

ToString() lambda expression

 Post Reply Post Reply
Author
jcrada View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Sep-2010
Location: Bogota
Posts: 6
Post Options Post Options   Quote jcrada Quote  Post ReplyReply Direct Link To This Post Topic: ToString() lambda expression
    Posted: 03-Sep-2010 at 5:23pm
Hi

Is there any way to use ToString() methods in a lambda expression with ideablade?
I have something like this
var query = Entities.DefaultManager.GetQuery<People>().AsQueryable();

and I want to filter some integers and doubles (for example person years old and Money ) with a textbox value

String searchText = TextEdit.Text;

query = query.Where(person =>  person.YearsOld.ToString().Contains(searchText) || 
person.Money.ToString().Contains(searchText)
);




Edited by jcrada - 04-Sep-2010 at 12:53pm
Back to Top
jcrada View Drop Down
Newbie
Newbie
Avatar

Joined: 03-Sep-2010
Location: Bogota
Posts: 6
Post Options Post Options   Quote jcrada Quote  Post ReplyReply Direct Link To This Post Posted: 04-Sep-2010 at 12:52pm
Finally I Figure out a solution for the problem , you have to use

Snippet
SqlFunctions.StringConvert((Double)person.YearsOld).Contains(searchText)

this must work fine the problem is that when you execute que query Ideablade throw an exception

"Execution of query against the server was successful but execution of query against the local cache failed"
Target Site {System.String StringConvert(System.Nullable`1[System.Double])}
{"This function can only be invoked from LINQ to Entities."}

if I change the query strategy to datasource only, the query is fine, and there is No exception, is there Ideablade
support for SqlFunctions, because they work for LINQ to Entities
thanks
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 09-Sep-2010 at 5:35pm
Hi,
 
Unfortunately, SqlFunctions methods have no "LINQ to Objects" implementation, they are only defined within a query against an Entity Framework backend (i.e. "LINQ to Entities").
 
As for using ToString() (in a lambda expression), since it is not supported by the Entity Framework, it can only be executed against the cache.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down