GithubHelp home page GithubHelp logo

多数据表操作 about vue.netcore HOT 3 CLOSED

cq-panda avatar cq-panda commented on September 26, 2024
多数据表操作

from vue.netcore.

Comments (3)

lvchaoin avatar lvchaoin commented on September 26, 2024

试了其它写法,有些写法不报错但是数据库没有写入,不知道啥情况,求指点
image

from vue.netcore.

cq-panda avatar cq-panda commented on September 26, 2024

第一个问题,你可以这样操作:
repository.DbContextBeginTransaction(() =>
{
repository.Add(new App_Expert()
{
City = ""
});
//其他表写法1
repository.AddRange(new List { new test2019() { text = "111" } });
//其他表写法2
repository.DbContext.Set().Add(new test2019() { text = "111" });
//其他表写法3
test2019Repository.Instance.Add(new test2019() { text = "111" },true);
//上面添加参数true或下面SaverChanges提交数据
repository.SaverChanges();
//如果这里返回Error会回滚事务
return new WebResponseContent().OK();
});

第二个问题:
你使用的是Dapper的Add方法,方法里面还没实现所以不会写入数据库,下次更新会把Add方法实现。
repository.DbContextBeginTransaction适用于需要多次提交SaverChanges。EF自带事务,看你上面的只是需要多张表同时提交,没必要使用 repository.DbContextBeginTransaction

from vue.netcore.

lvchaoin avatar lvchaoin commented on September 26, 2024

多谢 !

from vue.netcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.