/// <summary> /// 添加一条记录 /// </summary> public int Add(AdminResource entity) { string sql = @"insert into [AdminResource] ([id], [className], [parentId], [parentPath], [orderId], [linkURL], [resourceType], [resourceId], [isAdmin]) values (@id, @className, @parentId, @parentPath, @orderId, @linkURL, @resourceType, @resourceId, @isAdmin)"; object param = new { id = entity.Id, className = entity.ClassName, parentId = entity.ParentId, parentPath = entity.ParentPath, orderId = entity.OrderId, linkURL = entity.LinkURL, resourceType = entity.ResourceType, resourceId = entity.ResourceId, isAdmin = entity.IsAdmin }; using (IDbConnection conn = OpenConnection()) { int count = conn.Execute(sql, param); return count; } }
/// <summary> /// 添加一条记录 /// </summary> public ResultSet Add(AdminResource entity) { Func<AdminResource, ResultStatus> validate = (_entity) => { return new ResultStatus(); }; Func<AdminResource, ResultStatus> op = (_entity) => { int ret = new AdminResourceDal().Add(entity); if (ret > 0) return new ResultStatus(); else return new ResultStatus() { Success = false, Code = StatusCollection.AddFailed.Code, Description = StatusCollection.AddFailed.Description }; }; return HandleBusiness(entity, op, validate); }