This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, My entity PurchaseOrder has an Id of type string. In my db (Oracle) this field is zero padded. When the user searches by the id they do not enter the extra blank spaces so I need to do a .Trim() on the "Id" field before I can perform a search to match the user provided input. I am trying to do a .ToString().Trim() but it fails wherever I have the .ToString().
Anytime I try to do .ToString() I get an error: "ORA-01722: invalid number" even thought Id type is also string and the same exact parameter (PONumber) is being passed. Do you know what might be causing this? Is there a work around for this or a better approach? Thanks sr |
|
|
I realize I can do .PadRight() in my .net code but still curious to know whey it breaks anytime I attempt to do .ToString() ? |
|
|
Because query objects are not LINQ. When you write this:
.NET calls Entity.Attribute("Id"), which returns a QueryExpression, then calls ToString on the QueryExpression (probably resulting in a string along the lines of Remember, As you have realised, what you need to do is zero-pad the comparand (PONumber). PONumber is a real value, not an expression, so you can call the full panoply of CLR functions on it and they will be processed during expression building. If you were in a situation where the function absolutely had to be applied to the Entity.Attribute("Id"), you would have to use the .Function method e.g. |
|
|
Thanks for the response, this makes a bit more clear. Looking at the syntax I thought the .ToString() operation was being converted into sql and being executed on db end, I realize that's not the case. I'd tried using the .Fucntion() method but couldn't get the right syntax or find documentation on it. Is the a place where I can find more examples on this? Also, for troubleshooting purposes, is there a way to see the SQL command being sent to the db? Thanks, sr |
|
|
For more info about using SQL functions, see http://www.mindscapehq.com/documentation/lightspeed/Advanced-Querying-Techniques/Invoking-SQL-Functions. You can see the SQL by setting the LightSpeedContext.Logger property e.g. |
|
|
Okay, thanks for you help. |
|