Custom Types without a TypeConverter

Posts   
 
    
sparq
User
Posts: 63
Joined: 14-Mar-2010
# Posted on: 06-Apr-2017 00:26:46   

Hi There,

Is it possible to override the default data type determined by LLBLGen designer for particular fields either in the designer or by modifying templates? (I'm using 2.6)

I'm using Oracle(10g) and it would be awesome to be able to change a System.Decimal to a System.Int32 (or System.Int16 to System.Int32 for smaller columns) without having to go through a type converter.

Essentially I want to change the IDataReader getter method used.

I'm more than happy to wear the responsibility of under/overflows - I just want to say "Trust me, GetInt32 will work"

Thanks, Ben

sparq
User
Posts: 63
Joined: 14-Mar-2010
# Posted on: 06-Apr-2017 00:42:09   

I just had a closer look at the generated code and it looks like IDataReader.GetValues is being used to return the entire record contents as an object array.

So - Is it possible to change the entityInclude.template to change the value of "TypeOfField"?

Here's a snippet from the template;


<[Foreach EntityField]>
        /// <summary> The <[EntityFieldName]> property of the Entity <[CurrentEntityName]><br/><br/>
        /// <[Foreach CustomProperty EntityField]>
        /// <[CustomPropertyName]>: <[CustomPropertyValue]><br/><[NextForeach]></summary>

Within that "Foreach CustomProperty EntityField" loop I would like to check if CustomPropertyName is "TypeOfField" and if so, replace the contents of TypeOfField with CustomPropertyValue.

That way I can add custom properties like "TypeOfField=System.Int32" and at least override the casting of types.

Could you let me know the syntax for that? <[If CustomPropertyName Eq? "TypeOfField"... how would this look?]>

sparq
User
Posts: 63
Joined: 14-Mar-2010
# Posted on: 06-Apr-2017 02:01:32   

OK sorry about this - just tested this and a straight cast from object[] containing decimal values results in a InvalidCastException.

Never mind about this question then - feel free to close the thread as this is an Oracle issue which can't be overcome so easily.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 07-Apr-2017 10:00:11   

object to decimal casts sometimes fail, you should use the .NET Convert.To* methods instead simple_smile

Frans Bouma | Lead developer LLBLGen Pro