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
|
We have a case when a Stored Procedure is supposed to return a string. But sometimes that value can be null. When the stored procedure is brought into the LightSpeed model it generates the following code: public string randomSP(System.Guid Id) { ProcedureParameter IdParameter = new ProcedureParameter("Id", Id); ProcedureQuery procedureQuery = new ProcedureQuery("randomSP", IdParameter); string valueToReturn = (string)Calculate(procedureQuery); return valueToReturn; } The line where it casts the returned value as string gives an error if the returned value is System.DBNull. If the code is changed to: string valueToReturn = Calculate(procedureQuery) as string; The 'as' keyword changes System.DBNull to null automatically. |
|
|
Guys any feedback on this? |
|
|
Yep this is on our list to make a fix for, the issue is just with the code gen template being generic and not taking this specific case into account. For now you can handle this by copying out the definition to a partial class, making the associated update to switch the explicit cast to use the as keyword and either remove the procedure from the designer or switch its generation mode to be none.
|
|