Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.6k views
in Technique[技术] by (71.8m points)

c# - Set transaction only one time in all entity DAL classes

I have multiple DAL classes which perform CRUD and take an transaction object. I want to assign transaction object only to one class, so it's set into all DAL classes..

Public Class Employee{
    Transactions trans = null
  public List<Emp> Save(){
    // Transaction Will  Use There So It can Save 
   }
}

Public Class Customer{
    Transactions trans = null
  public List<Cst> Save(){
    // Transaction Will  Use There So It can Save 
   }
}

Public Static Void Main(String[] args ){
SqlTransaction trans = db.BeginTransactions();
Employee emp = new Employee();
emp.trans;
Customer cst = new Customer();
cst.trans;

}

In the code above you can see all Instances I have to pass to transaction object. Every instance of DAL I create like Shop, Company etc.. I want to get rid off this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...