public void DeleteOneStudentTest() { var model = new UserStudentsModel { Id = 2 }; var result = Singleton <UserStudentsService> .Instance .DeleteOneUserStudentsModel(model); Assert.IsTrue(result); }
public void UpdateOneUserStudentsModelTest() { var model = new UserStudentsModel { Id = 1, Age = 100 }; var result = Singleton <UserStudentsService> .Instance.UpdateOneUserStudentsModel(model); Assert.IsTrue(result); }
public void UpdateUserStudentsModelsByConditionTest() { var model = new UserStudentsModel { Age = 444 }; var result = Singleton <UserStudentsService> .Instance.UpdateUserStudentsModelsByCondition( model, x => x.Id > 0 && x.Name.Contains("你猜猜%")); Assert.IsTrue(result); }
/// <summary> /// 更新单个UserStudentsModel实体模型 /// </summary> /// <typeparam name="TElement"></typeparam> /// <param name="entity"></param> /// <returns></returns> public bool UpdateOneUserStudentsModel(UserStudentsModel entity) { var result = false; try { result = dal_UserStudents.Update(entity) > 0 ? true : false; } catch (Exception ex) { throw ex; } return(result); }
/// <summary> /// 通过特定的条件查询出UserStudentsModel元素 /// </summary> /// <param name="predicate"></param> /// <returns></returns> public UserStudentsModel GetUserStudentsElementByCondition(Expression <Func <UserStudentsModel, bool> > predicate) { UserStudentsModel result = null; try { result = dal_UserStudents.GetFirstOrDefaultByCondition(predicate); } catch (Exception ex) { throw ex; } return(result); }
/// <summary> /// 通过主键获取单个UserStudentsModel元素 /// </summary> /// <param name="id">Identifier</param> /// <returns>Entity</returns> public UserStudentsModel GetUserStudentsElementById(int id) { UserStudentsModel result = null; try { result = dal_UserStudents.GetElementById(id); } catch (Exception ex) { throw ex; } return(result); }
/// <summary> /// 更新UserStudentsModel元素 通过 符合条件的 /// </summary> /// <param name="entity">携带值的载体</param> /// <param name="predicate">条件</param> /// <returns></returns> public bool UpdateUserStudentsModelsByCondition(UserStudentsModel entity, Expression <Func <UserStudentsModel, bool> > predicate) { var result = false; try { result = dal_UserStudents.UpdateByCondition(entity, predicate) > 0 ? true : false; } catch (Exception ex) { throw ex; } return(result); }
public void AddOneUserStudentsModelTest() { //var model = new UserStudentsModel //{ // Name = "你猜猜-" + DateTime.Now.ToString(), // Age = DateTime.Now.Second, // Sex = true, // Score = 55.98m, // Longitude = 555555.6666, // AddTime = DateTime.Now //}; //var result = serviceOfStudents.AddOneUserStudentsModel(model); var watch = new System.Diagnostics.Stopwatch(); watch.Start(); var model = new UserStudentsModel { Name = "你猜222222222猜-" + DateTime.Now.ToString(), Age = DateTime.Now.Second, Sex = true, Score = 6655.98m, Longitude = 99999999, AddTime = DateTime.Now, HasPay = 888, HomeNumber = 666 }; var result = Singleton <UserStudentsService> .Instance.AddOneUserStudentsModel(model); watch.Stop(); Console.WriteLine(string.Format("real for insert one data use time is :{0} ms.", watch.ElapsedMilliseconds)); Assert.IsTrue(result); }
/// <summary> /// 添加单个UserStudentsModel对象方法(可返回对应数据表中 的此实体ID) /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool AddOneUserStudentsModel(UserStudentsModel entity) { var result = false; try { var entityID = dal_UserStudents.Insert(entity); if (entityID > 0) { entity.Id = entityID; result = true; } } catch (Exception ex) { throw ex; } return(result); }
public BusinessViewModelContainer <bool> AddMulitiUserStudentsModelsTest() { var viewModel = new BusinessViewModelContainer <bool>(); var lstData = new List <UserStudentsModel>(); var rand = new Random(DateTime.Now.Millisecond); for (int i = 0; i < 100; i++) { var model = new UserStudentsModel { Name = "你猜猜-" + Guid.NewGuid().ToString(), Age = rand.Next(1, 100), Sex = false, Score = 33355.98m, Longitude = 59595959, AddTime = DateTime.Now, HasPay = 888, HomeNumber = 666 }; lstData.Add(model); } using (var tran = new TransactionScope()) { var lstStudents = Singleton <UserStudentsService> .Instance.GetUserStudentsElementById(1); var result = Singleton <UserStudentsService> .Instance.AddMulitiUserStudentsModels(lstData); viewModel.Data = result; tran.Complete(); } return(viewModel); }
public void AddMulitiUserStudentsModelsTest() { var lstData = new List <UserStudentsModel>(); var rand = new Random(DateTime.Now.Millisecond); for (int i = 0; i < 100; i++) { var model = new UserStudentsModel { Name = "你猜猜-" + Guid.NewGuid().ToString(), Age = rand.Next(1, 100), Sex = false, Score = 33355.98m, Longitude = 59595959, AddTime = DateTime.Now, HasPay = 888, HomeNumber = 666 }; lstData.Add(model); } var result = Singleton <UserStudentsService> .Instance.AddMulitiUserStudentsModels(lstData); Assert.IsTrue(1 == 1); }