/// <summary> /// /// </summary> /// <returns></returns> //public long Update() //{ // var result = Update<SysJobLog>(q => new SysJobLog() { Message = "修改Mess", Name = "修改的信息" }, q => q.JobLogId == 4 ); // return result; //} #region 所有查询 /// <summary> /// 同步查询示例 /// </summary> /// <param name="id"></param> /// <returns></returns> public SysJobLog GetEntity(int id) { SysJobLog entity = FirstOrDefault <SysJobLog>(q => q.JobLogId == 13); LessLog.Info("我是一条测试日志"); var json = typeof(EnumMemUserType).ToJson(); var des = EnumMemUserType.QQType.GetDescription(); return(entity); }
/// <summary> /// 异步插入 /// </summary> /// <returns></returns> public async Task <ResponseResult> AddAsync() { ResponseResult result = new ResponseResult(); SysJobLog jobLogEntity = new SysJobLog() { Name = "测试", JobLogType = 1, ServerIp = "::", TaskLogType = 1, Message = "测试消息", CreateTime = DateTime.Now }; SysLog jobEntity = new SysLog() { Logger = "测试数据", Level = "测试等级", Ip = "::", DeleteFlag = false, LogType = 1, Message = "测试数据", SubSysId = 1, SubSysName = "测试子名称", Thread = "测试数据", Url = "http://www.jinglih.com/", MemberName = "17623827239", CreateTime = DateTime.Now, Exception = "测试异常信息" }; ////常规的写法 using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { //执行action await InsertAsync(jobEntity); await InsertAsync(jobLogEntity); //锁表查询测试 SysLog logEntity = await FirstOrDefaultAsync <SysLog>(q => q.LogId == 86); SysJobLog entity = await FirstOrDefaultAsync <SysJobLog>(q => q.JobLogId == 13); //提交事务 scope.Complete(); } return(result); }
static void Insert() { #region 新增1 for (int i = 0; i < 100; i++) { SysJobLog sysJobLog = new SysJobLog() { JobLogType = 1, Message = "aaaa" + i, Name = "a", ServerIp = "127.0.0.1", TaskLogType = 1, CreateTime = DateTime.Now, }; intFlag = service.Insert(sysJobLog); Console.WriteLine("新增数据状态值(返回当前一条语句状态):" + intFlag); } #endregion #region 新增2 List <SysJobLog> jobList = new List <SysJobLog>(); for (int i = 0; i < 100; i++) { SysJobLog sysJobLog = new SysJobLog() { JobLogType = 1, Message = "aaaa" + i, Name = "a", ServerIp = "127.0.0.1", TaskLogType = 1, CreateTime = DateTime.Now, }; jobList.Add(sysJobLog); } intFlag = service.Insert(jobList); Console.WriteLine("新增数据状态值(返回List集合数):" + intFlag); #endregion }