|
TextCommand(Func argument_Command);
10 DatabaseOperation WidthExecuteTextCommand(Func argument_Command);
11 DatabaseOperation WidthExecuteProcedureCommand(Func argument_Command);
12 }
?
1 public sealed class DatabaseOperation : IOperation
2 {
3 public DatabaseOperation()
4 {
5 this._Provide = new Database();
6 this.Initialization();
7 }
8
9 public DatabaseOperation(string argument_ProvideName)
10 {
11 this._Provide = new Database(argument_ProvideName);
12 this.Initialization();
13 }
14
15 public DatabaseOperation(string argument_ProvideName,string argument_ConnectionString)
16 {
17 this._Provide = new Database(argument_ProvideName, argument_ConnectionString);
18 this.Initialization();
19 }
20
21 public DatabaseOperation(Database argument_Provide)
22 {
23 this._Provide = argument_Provide;
24 this.Initialization();
25 }
26
27 private DatabaseConnection _ConnectionProvide = null;
28 private DatabaseCommandText _NextTextCommand = null;
29 private DatabaseCommandProcedure _NextProcedureProvide = null;
30 private Database _Provide = null;
31 private DbTransaction _Transaction = null;
32
33
34 public Dictionary CommandValues { get; private set; }
35
36 private void Initialization()
37 {
38 this.CommandValues = new Dictionary();
39 this._ConnectionProvide = new DatabaseConnection(this._Provide);
40 }
41
42 public DatabaseOperation ExecuteTextCommand(Func argument_Command)
43 {
44 _NextTextCommand = new DatabaseCommandText(this._ConnectionProvide);
45 OperationValue _Value = argument_Command.Invoke(_NextTextCommand);
46 this.CommandValues.Clear();
47 this.CommandValues.Add(_NextTextCommand.CommandName, _Value);
48 return this;
49 }
50
51 public DatabaseOperation ExecuteTextCommand(Func argument_Command)
52 {
53 if (null == this._Transaction)
54 {
55 throw new NullReferenceException("没有检测到事务的开始");
56 }
57
58 _NextTextCommand = new DatabaseCommandText(this._ConnectionProvide);
59 OperationValue _Value = argument_Command.Invoke(_NextTextCommand, this._Transaction);
60 this.CommandValues.Clear();
61 this.CommandValues.Add(_NextTextCommand.CommandName, _Value);
62 return this;
63 }
64
65 public DatabaseOperation WidthExecuteTextCommand(Func argument_Command)
66 {
67 _NextTextCommand = new DatabaseCommandText(this._ConnectionProvide);
68 OperationValue _Value = argument_Command.Invoke(_NextTextCommand);
69 CommandValues.Add(_NextTextCommand.CommandName, _Value);
70 return this;
71 }
72
73 public DatabaseOperation WidthExecuteTextCommand(Func argument_Command)
74 {
75 if (null == this._Transaction)
76 {
77 throw new NullReferenceException("没有检测到事务的开始");
78 }
79
80 this._NextTextCommand = new DatabaseCommandText(this._ConnectionProvide);
81 OperationValue _Value = argument_Command.Invoke(this._NextTextCommand, this._Transaction);
82 CommandValues.Add(_NextTextCommand.CommandName, _Value);
83 return this;
84 }
85
86 public DatabaseOperation ExecuteProcedureCommand(Func argument_Command)
87 {
88 _NextProcedureProvide = new DatabaseCommandProcedure(this._ConnectionProvide);
89 OperationValue _Value = argument_Command.Invoke(_NextProcedureProvide);
90 this.CommandValues |