与DataAccess.Client.OracleConnection共享ManagedDataAccess.Client.OracleConnection连接/会话/事务

在我的应用程序中,我正在使用具有public Oracle.ManagedDataaccess.Client.OracleConnection DbConn属性的Repository类。在另一个使用该存储库的类中,有一个特殊的用例,我需要使用OracleBulkCopy来从access文件中快速导入数据,不幸的是,Oracle Managed nuget仍然不支持这种情况。因此,我需要实例化一个Oracle.Dataaccess.Client.OracleConnection并基于该连接创建OracleBulkCopy。但是我想将整个过程都保留在事务中,包括通过存储库的连接所做的更改和“非托管” OracleConnection所做的更改。我看到完成的唯一方法是将存储库的Oracle.ManagedDataaccess.Client.OracleConnection中的基础连接/会话/事务“共享”到Oracle.Dataaccess.Client.OracleConnection。 这样有可能吗?

谢谢。

kylin177 回答:与DataAccess.Client.OracleConnection共享ManagedDataAccess.Client.OracleConnection连接/会话/事务

如果您的存储库具有属性

import React from 'react';
import { render } from "react-dom";
import styled from 'styled-components'
import { Button,Grid,Container} from 'semantic-ui-react'
import PropTypes from 'prop-types'

const mID = 'test'

const StyledBlock = styled(Container)`
{/*i don't want to style here */}
  background-color: yellow ;
  height: 450px;
  @media only screen and (max-width: 767px) and (min-width: 320px) {
    height: 550px;
  }
  > * { //applies for all under parent class,class that is applied by SC on parent
    color: magenta
  }
  & .${mID}__column{ //all elements under & i.e parent class (which is StyledBlock) with class {mID}__column
    color :green;
  }
`
const StyledSection = styled.section`
  background: #ffffff;
  box-shadow: 0px 1px 0px #dfdfdf;
  margin: 12% 10% 10% 30%;
  height: 150px;
  width: 170px;
  @media only screen and (max-width: 767px) and (min-width: 320px) {
    margin: 10% 0 25% 25%;
    width: 172px;
  }
`
const Header = styled.h4`
  text-align: center;
  position: relative;
  top: 10%;
`
const StyledButton = styled(Button)`
  position: relative;
  bottom: -60px;
  margin: 0px;
  width: 100%;
  top: 9.32%;
`

const Report = (name) => {
  const handleClick = async (e) => {
    console.log(e)
  }

  return (
    <Grid.Column key={name} className={`${mID}__column`}>
      <StyledSection>
        <Header>{name}</Header>
        <StyledButton secondary onClick={() => handleClick(name)} >
          Download
        </StyledButton>
      </StyledSection>
    </Grid.Column>
  )
}

const Reports = ({className}) => {
  console.log('className ',className)
return(
  <Container className={className}>
    <StyledBlock>
      <Grid>
        <Grid.Row>{["deen","john"].map((name) => Report(name))}</Grid.Row>
      </Grid>
    </StyledBlock>
  </Container>
)}

Reports.propTypes = {
  names: PropTypes.array,onlineShowId: PropTypes.number
}

const StyledReports = styled(Reports)`
   background-color:blue; //to apply this,SC need a className on this element to apply
 .${mID} {
    &__column {
      color: gold
    }
 }

 ${StyledBlock}{
  background-color: red  ; //higher specificity than in styledblock
 }
`

render(<StyledReports />,document.getElementById("root"))

您可以通过使用基类对此进行抽象

Oracle.ManagedDataAccess.Client.OracleConnection DbConn

现在,根据您需要的功能,您可以传递System.Data.Common.DbConnection DbConn Oracle.ManagedDataAccess.Client.OracleConnection

大多数功能对这两个版本均适用,但是Oracle.DataAccess.Client.OracleConnection仅对非托管版本有效。因此,在您的代码中,只需

BulkCopy
本文链接:https://www.f2er.com/2418969.html

大家都在问