/// <summary> /// /// </summary> /// <param name="pointId"></param> /// <param name="pointTable"></param> /// <returns></returns> public MessageEntity UpdatePointTableByPointId(PointAreaInfo pointTable) { using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.PipeInspectionBase_Gis_OutSide)) { var rows = 0; string sql = $@"select count(0) as count from PointAreaInfo p where p.PlanAreaId = {pointTable.PlanAreaId} and p.PointName='{ pointTable.PointName}'"; List <dynamic> pointcc = conn.Query <dynamic>(sql).ToList(); if (pointcc[0].count > 0) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, "同一区域内不能添加相同关键点")); } var updateSql = DapperExtentions.MakeUpdateSql(pointTable); if (string.IsNullOrEmpty(updateSql)) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类")); } try { rows = conn.Execute(updateSql, pointTable); return(MessageEntityTool.GetMessage(rows)); } catch (Exception e) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message)); } } }
public MessageEntity UpdateEventType(M_EventType eventType) { using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.PipeInspectionBase_Gis_OutSide)) { var rows = 0; var excSql = DapperExtentions.MakeUpdateSql(eventType); if (string.IsNullOrEmpty(excSql)) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类")); } try { rows = conn.Execute(excSql, eventType); return(MessageEntityTool.GetMessage(rows)); } catch (Exception e) { return(MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message)); } } }
public int UpdateEntity(object entity, ConnectionFactory.DBConnNames dBConnName, out MessageEntity messageEntity) { using (var conn = ConnectionFactory.GetDBConn(dBConnName)) { var rows = 0; var updateSql = DapperExtentions.MakeUpdateSql(entity); if (string.IsNullOrEmpty(updateSql)) { messageEntity = MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类"); return(0); } try { rows = conn.Execute(updateSql, entity); messageEntity = MessageEntityTool.GetMessage(rows); } catch (Exception e) { messageEntity = MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message); } return(rows); } }