Hi all,
I am new to CSLA.I am learning it to implement it in one of the project.We have a functionality in UI screen where the user is allowed to check the checkboxes to show/hide grid columns.Here the UI is sending the grid configuration details as an XML data and UserID to the CSLA business objects . I m trying to perform batch updation to the db by invoking the business objects's DataPortal_Update method through save method in UI.But the save method is not invoking the Data_Portal method.
#region
Data Access - Updateprotected override void DataPortal_Update()
{
using (SqlConnection cn = new SqlConnection(DataAccess.Connection))
{
cn.Open();
ExecuteUpdate(cn);
}
}
protected void ExecuteUpdate(SqlConnection cn)
{
using (SqlCommand command = new SqlCommand("spUpdateGridConfig", cn))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@configGridXML", configGridXML);
command.Parameters.AddWithValue("@UserID", userID);
command.ExecuteNonQuery();
}
}
#endregion
I just want to know how to perform batch updation using business objects with XML data.The business objects is not set as IsDirty.
Thanks
Jash
You wrote :
" .. invoking the business objects's DataPortal_Update method through save method in UI."
It is not possible. The BO DataPortal_Update must be call by a factory method placed in the same business class in which DataPortal_Update is.
Public Overrides Function Save() As Project
Return MyBase.Save
End Function
Your UI call this factory method (Save).
Then this factory method (Save) call DataPortal_Update automagicaly with CSLA.
Dominique
Hi,
do this in the parent update method:
protected override void DataPortal_Update()
{
child_Update();
}
Hi,
In your Business objects: while defining the property: do like the below:
Fields: string _name;
Public string Name
{
set
{
if( _name != value)
{
_name = value;
PropertyHasChanged() -> This will make the object as dirty.
} Yesterday, I got the same propblem. I defined the property like the above, it solved my problem.
The business objects is not set as IsDirty.
That means the data portal won't call Update it will call Insert.
So just do this if Inserrt means the same thing as Update to you:
protected override void DataPortal_Insert()
{
DataPortal_Update()
}
Joe
Copyright (c) Marimer LLC