Code Fragment :
protected void Button1_Click(object sender, EventArgs e)
{
//add a new setting.
SettingEntity se = new SettingEntity();
se.SName = "KKTest12";
se.SectorId = 1;
se.Active = "Y";
se.UpdateWho = "KK";
try
{
se.Save();
int sid = se.Sid;
}
catch (Exception Ex)
{
string err = Ex.Message;
}
}
The error occurs only when you try to access a property (any property) of the entity and not when you call the Save() method. But the Save() method seems to cause some error internally.
Just to recap, the setting are :
In the LLBLGen Designer:
"is identity/sequence" true
"read only" true
"sequence name" = PPS_CUSTOM.PPS_SID_SEQ
In the web.config file
<add key="OracleTriggerSequences" value="true" />
LLBLGen runtime version v2.0.50727
Exception and StackTrace :
System.InvalidCastException was caught
Message="Specified cast is not valid."
Source="PPS.DAL"
StackTrace:
at PPS.DAL.EntityClasses.SettingEntityBase.get_Sid() in C:\PPS_DAL\EntityBaseClasses\SettingEntityBase.cs:line 1240
at PPS.DAL.EntityClasses.SettingEntityBase.Refetch() in C:\PPS_DAL\EntityBaseClasses\SettingEntityBase.cs:line 475
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.CheckForRefetch()
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.GetValue(Int32 fieldIndex, Boolean returnDefaultIfNull)
at PPS.DAL.EntityClasses.SettingEntityBase.get_Sid() in C:\PPS_DAL\EntityBaseClasses\SettingEntityBase.cs:line 1240
at Test.Button1_Click(Object sender, EventArgs e) in d:\Documents and Settings\kkrishna\My Documents\Visual Studio 2005\WebSites\PPS\Test.aspx.cs:line 35
InnerException: