本文整理汇总了C#中PetaPoco.Database.AbortTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# PetaPoco.Database.AbortTransaction方法的具体用法?C# PetaPoco.Database.AbortTransaction怎么用?C# PetaPoco.Database.AbortTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PetaPoco.Database
的用法示例。
在下文中一共展示了PetaPoco.Database.AbortTransaction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateStudent
public bool UpdateStudent(StudentViewModel objViewModel)
{
PetaPoco.Database db = new PetaPoco.Database("DBConnectionString");
DBConnectionString.User user = DBConnectionString.User.SingleOrDefault(objViewModel.UserId);
DBConnectionString.Student student = DBConnectionString.Student.SingleOrDefault(objViewModel.StudentId);
DBConnectionString.Profile profile = db.Query<DBConnectionString.Profile>("Select * from profile where UserId = @0", student.UserId).SingleOrDefault();
db.BeginTransaction();
try
{
if (user != null)
{
user.FirstName = objViewModel.FirstName;
user.LastName = objViewModel.LastName;
user.Update();
}
if (student != null)
{
student.ClassId = objViewModel.ClassId;
student.CourseId = objViewModel.CourseId;
student.DepartmentId = objViewModel.DepartmentId;
student.Email = objViewModel.Email;
student.FullName = objViewModel.FirstName + " " + objViewModel.LastName;
student.ModifiedBy = objViewModel.ModifiedBy;
student.ModifiedOn = objViewModel.ModifiedOn;
student.SectionId = objViewModel.SectionId;
student.Update();
}
if (profile != null)
{
profile.Title = objViewModel.Title;
profile.DateOfBirth = objViewModel.DateOfBirth;
profile.MobileNumber = objViewModel.MobileNumber;
profile.HomeTelephoneNumber = objViewModel.HomeTelephoneNumber;
profile.EmailAddress1 = objViewModel.Email;
profile.Update();
}
//var subjectIdArray = objViewModel.SubjectIds.Split(',');
//foreach (var subjectId in subjectIdArray)
//{
// DBConnectionString.UserSubject userSubject = db.Query<DBConnectionString.UserSubject>("select * from UserSubjects where UserId = @0 and SubjectId = @1", objViewModel.UserId, subjectId).SingleOrDefault();
// if (userSubject == null)
// {
// userSubject.UserId = objViewModel.UserId.Value;
// userSubject.SubjectId = Convert.ToInt64(subjectId);
// userSubject.InsertedOn = DateTime.Now;
// userSubject.InsertedBy = objViewModel.InsertedBy;
// userSubject.Update();
// }
//}
db.CompleteTransaction();
return true;
}
catch
{
db.AbortTransaction();
return false;
}
}