i have a very simple program for manipulating two tables in a SQL 2000 database, this project is written in ASP.Net 1.1 (becuase another section thats already written is in 1.1).
Background:
there are two tables
1) posting
PK - JobId int
2) Listing
PK - ListId int
FK - JoibId int
I already have everything up and working except when it comes to updateing an entry. In the LLBLgen designer i didn't specify any thing that was not already in the schema for the DB (mostly because i have been using it for about 2 days :0)
Problem:
the problem arises when i try to modify an entity that was just fetched. it turns out that if i save the entity using the adapter it doesn't seem to be using the fetched entity at all because it keeps telling me that i didn't set a required field on the entity. the field was not modified in the editing process and i did verify that it is there on the entity that i fetched.
the required field is a createdate on the entity
An exception was caught during the execution of an action query: Cannot insert the value NULL into column 'CreateDate', table 'dbo.JobDB_Posting'; column does not allow nulls. INSERT fails. The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
[ORMQueryExecutionException: An exception was caught during the execution of an action query: Cannot insert the value NULL into column 'CreateDate', table 'DPSQ440.DPSQ440_RAIN.JobDB_Posting'; column does not allow nulls. INSERT fails.
The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.]
SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute() +668
SD.LLBLGen.Pro.ORMSupportClasses.BatchActionQuery.Execute() +90
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteActionQuery(IActionQuery queryToExecute) +134
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.PersistQueue(ArrayList queueToPersist, Boolean insertActions) +1199
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave, Boolean refetchAfterSave, IPredicateExpression updateRestriction, Boolean recurse) +1078
SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.SaveEntity(IEntity2 entityToSave) +40
Job.Core.Managers.PostingManager.Save(JobDbPostingEntity post) +58
JobUI.Common.Controls.Content.JobEdit.SaveButton_Click(Object sender, EventArgs e) +631
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
LLBLgen ver. 1.0.2005.1 Final
code template: Adapter scenario (full/safe)(1.0.2005.1.03032006)
database template: c# template for sqlserver (1.0.2005.1)(1.0.2005.1.111705)
Connection.cs
Adapter property:
public DataAccessAdapter Adapter
{
get
{
string connectionString = String.Empty;
string catalogName = String.Empty;
string schemaName = String.Empty;
catalogName = ConfigurationSettings.AppSettings["CatalogName"];
schemaName = ConfigurationSettings.AppSettings["SchemaName"];
if (IsLive == "0")
connectionString = ConfigurationSettings.AppSettings["LocalConnectionString"];
else
connectionString = ConfigurationSettings.AppSettings["LiveConnectionString"];
CatalogNameOverwriteHashtable catalogChange = new CatalogNameOverwriteHashtable();
catalogChange.Add("DPSQ440", catalogName);
SchemaNameOverwriteHashtable schemaChange = new SchemaNameOverwriteHashtable();
schemaChange.Add("DPSQ440_RAIN", schemaName);
DataAccessAdapter adapter = new DataAccessAdapter(connectionString, false, catalogChange, schemaChange);
adapter.CommandTimeOut = 180;
return adapter;
}
}
Save code:
public PostEntity Save(PostEntity post)
{
Connection connection = new Connection();
using(DataAccessAdapter adapter = connection.Adapter)
{
adapter.SaveEntity(post);
}
return post;
}
public ListingEntity Save(ListingEntity listing)
{
Connection connection = new Connection();
using(DataAccessAdapter adapter = connection.Adapter)
{
adapter.SaveEntity(listing);
}
return listing;
}