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, I am attempting to use the SQL Function CAST in my Query object: q.Projection.Add(Entity.Attribute("Value").Function("CAST", "Decimal").Function("AVG")); (The column Value is a text column, whose records I have previously filtered by IsNumeric) The problem I get is that the SQL generated for CAST has taken the "decimal" argument as a string, resulting in: AVG(CAST(xxx.Value AS "DECIMAL")) AS [xxx.ValueCASTAVG] Is there any way to specify the argument to CAST as a literal and not a string? This is what I expect: AVG(CAST(xxx.Value AS DECIMAL)) AS [xxx.ValueCASTAVG] Thanks - Imtiaz |
|
|
Yep you can do this by passing a LiteralExpression as the value argument to the function rather than the literal value which gives you control over how the literal is handled. e.g.
Note the use of the EmitInline property on the LiteralExpression which triggers this to be rendered without the quoting.
|
|