Update of /cvsroot/nugsoft/nugsoft/nUGSoft.Entities
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8744/nUGSoft.Entities
Modified Files:
EntityBase.cs Person.cs
Log Message:
Got rid of Person.UpdateList and added EntityBase.Update(EntityBase) and Person.Update(Person). Need the override method in derived classes due to ObjectDataSource requirement.
Index: Person.cs
===================================================================
RCS file: /cvsroot/nugsoft/nugsoft/nUGSoft.Entities/Person.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Person.cs 4 Dec 2005 04:00:22 -0000 1.5
--- Person.cs 4 Dec 2005 20:49:33 -0000 1.6
***************
*** 326,336 ****
return Person.Find<Person>(hql);
}
!
! public static void UpdatePersonList(IList list)
{
! foreach (Person pers in list)
! {
! pers.Update();
! }
}
--- 326,338 ----
return Person.Find<Person>(hql);
}
!
! /// <summary>
! /// Updates the specified Person entity. Overridden in Person because
! /// ObjectDataConnector can't use EntityBase.Update(EntityBase ent).
! /// </summary>
! /// <param name="pers">The pers.</param>
! public void Update(Person pers)
{
! EntityBase.Update(pers);
}
Index: EntityBase.cs
===================================================================
RCS file: /cvsroot/nugsoft/nugsoft/nUGSoft.Entities/EntityBase.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** EntityBase.cs 29 Nov 2005 02:18:43 -0000 1.2
--- EntityBase.cs 4 Dec 2005 20:49:33 -0000 1.3
***************
*** 207,210 ****
--- 207,226 ----
}
}
+
+ public static void Update(EntityBase ent)
+ {
+ if (!ent.IsValid)
+ {
+ throw new ValidationException(ent.ValidationErrors);
+ }
+
+ using (Repository repository = new Repository())
+ {
+ repository.Open();
+ repository.BeginTransaction();
+ repository.Update(ent);
+ repository.CommitTransaction();
+ }
+ }
/// <summary>
|