Hello.
I'm using LLBL 5.3 (5.3.0) RTM and .net 4.5.2, connecting to sql server 2005 and ora11g databases, db first, adapter model.
I have a problem with a field that's number(4) in the database. In the Oracle version, the LLBL designer sees the field directly as short. In the Sql Server version, it's seen as decimal, so I used the SD.LLBLGen.Pro.TypeConverters.Int16DecimalConverter on it.
The generated code (c#,platform .NET 4.5.2, SD.Presetds.Adapter.General) is
/// <summary> The SREF_MAINTENANCE property of the Entity STOCK<br/><br/></summary>
/// <remarks>Mapped on table field: "STOCK"."SREF_MAINTENANCE"<br/>
/// Table field type characteristics (type, precision, scale, length): Decimal, 4, 0, 0<br/>
/// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
public virtual System.Int16 SREF_MAINTENANCE
{
get { return (System.Int16)GetValue((int)STOCKFieldIndex.SREF_MAINTENANCE, true); }
set { SetValue((int)STOCKFieldIndex.SREF_MAINTENANCE, value); }
}
After fetching an entity, when trying to get the value, '((ASTech.LLBL.EntityClasses.STOCKEntity)entityToSave).SREF_MAINTENANCE' threw an exception of type 'System.InvalidCastException'
" at ASTech.LLBL.EntityClasses.STOCKEntity.get_SREF_MAINTENANCE() in R:\\astech.llbl\\trunk\\EntityClasses\\STOCKEntity.cs:line 3247"
GetValue((int)STOCKFieldIndex.SREF_MAINTENANCE, true) return 0, which obviously cannot be converted to short
Am I doing something wrong?
I see the generated code for the ooooooold version (v1) we've been using until recently looks completely different
public virtual System.Int16 SREF_MAINTENANCE
{
get
{
object valueToReturn = base.GetCurrentFieldValue((int)STOCKFieldIndex.SREF_MAINTENANCE);
if(valueToReturn == null)
{
valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int16));
}
return Convert.ToInt16(valueToReturn);
}
set
{
if(SetNewFieldValue((int)STOCKFieldIndex.SREF_MAINTENANCE, value))
{
OnSREF_MAINTENANCEChanged();
}
}
}
Should I make a change in the templates or something?
Thanks