📄 element.cs
字号:
count.Name = "AVG";
count.ReturnType = new CodeTypeReference(typeof(object));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(string)), "field"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(bool)), "DISTINCT"));
mEntity.Members.Add(count);
count.Statements.Add(context);
count.Statements.Add(setcontext);
trycatch = new CodeTryCatchFinallyStatement();
count.Attributes = MemberAttributes.Public | MemberAttributes.Static;
count.Statements.Add(trycatch);
trycatch.TryStatements.Add(
new CodeMethodReturnStatement(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(
new CodeTypeReferenceExpression(Name), "AVG"),
new CodeVariableReferenceExpression("_context"),
new CodeArgumentReferenceExpression("field"),
new CodeArgumentReferenceExpression("DISTINCT"),
new CodePrimitiveExpression(null))));
_catch = new CodeCatchClause("e_", new CodeTypeReference(typeof(Exception)));
_catch.Statements.Add(new CodeThrowExceptionStatement(new CodeVariableReferenceExpression("e_")));
trycatch.CatchClauses.Add(_catch);
trycatch.FinallyStatements.Add(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(new CodeVariableReferenceExpression("_context"),
"Dispose")));
}
private void BuilderDeleteObject() {
CodeMemberMethod del = new CodeMemberMethod();
del.Name = "Delete";
del.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.IConnectinContext(), "context"));
del.Attributes = MemberAttributes.Public;
mEntity.Members.Add(del);
del.Statements.Add(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(
new CodeThisReferenceExpression(), "OnDeleteObject"),
new CodeArgumentReferenceExpression("context"),
new CodePrimitiveExpression(Table),
new CodePrimitiveExpression(ID.Column),
new CodePropertyReferenceExpression(
new CodeThisReferenceExpression(), ID.Name)));
CodeVariableDeclarationStatement context = new CodeVariableDeclarationStatement(TypeReferenceFactory.IConnectinContext(), "_context");
CodeAssignStatement setcontext = GetContext();
CodeTryCatchFinallyStatement trycatch = new CodeTryCatchFinallyStatement();
CodeCatchClause _catch;
del = new CodeMemberMethod();
del.Name = "Delete";
del.Attributes = MemberAttributes.Public;
mEntity.Members.Add(del);
del.Statements.Add(context);
del.Statements.Add(setcontext);
del.Statements.Add(trycatch);
_catch = new CodeCatchClause("e_", new CodeTypeReference(typeof(Exception)));
_catch.Statements.Add(new CodeThrowExceptionStatement(new CodeVariableReferenceExpression("e_")));
trycatch.CatchClauses.Add(_catch);
trycatch.TryStatements.Add(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(
new CodeThisReferenceExpression(), "Delete"),
new CodeVariableReferenceExpression("_context")));
trycatch.FinallyStatements.Add(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(new CodeVariableReferenceExpression("_context"),
"Dispose")));
}
private void BuilderDelete() {
CodeMemberMethod del = new CodeMemberMethod();
del.Name = "Delete";
del.Attributes = MemberAttributes.Public | MemberAttributes.Static;
del.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.IConnectinContext(), "context"));
del.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.WhereBody(), "expression"));
del.Statements.Add(
new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("EntityBase"),
"OnDelete",
new CodeArgumentReferenceExpression("context"),
new CodePrimitiveExpression(Table),
new CodeArgumentReferenceExpression("expression")));
mEntity.Members.Add(del);
CodeVariableDeclarationStatement context = new CodeVariableDeclarationStatement(TypeReferenceFactory.IConnectinContext(), "_context");
CodeAssignStatement setcontext = GetContext();
CodeTryCatchFinallyStatement trycatch = new CodeTryCatchFinallyStatement();
CodeCatchClause _catch;
del = new CodeMemberMethod();
del.Name = "Delete";
del.Attributes = MemberAttributes.Public | MemberAttributes.Static;
del.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.WhereBody(), "expression"));
mEntity.Members.Add(del);
del.Statements.Add(context);
del.Statements.Add(setcontext);
del.Statements.Add(trycatch);
_catch = new CodeCatchClause("e_", new CodeTypeReference(typeof(Exception)));
_catch.Statements.Add(new CodeThrowExceptionStatement(new CodeVariableReferenceExpression("e_")));
trycatch.CatchClauses.Add(_catch);
trycatch.TryStatements.Add(
new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(Name),
"Delete",
new CodeVariableReferenceExpression("_context"),
new CodeArgumentReferenceExpression("expression")));
trycatch.FinallyStatements.Add(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(new CodeVariableReferenceExpression("_context"),
"Dispose")));
}
private void BuilderSUM()
{
CodeMemberMethod count = new CodeMemberMethod();
count.Name = "SUM";
count.ReturnType = new CodeTypeReference(typeof(object));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.IConnectinContext(), "context"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(string)), "field"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(bool)), "DISTINCT"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.WhereBody(), "expression"));
count.Attributes = MemberAttributes.Public | MemberAttributes.Static;
mEntity.Members.Add(count);
count.Statements.Add(
new CodeMethodReturnStatement(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(
new CodeTypeReferenceExpression("EntityBase"), "OnAggregation"),
new CodeArgumentReferenceExpression("context"),
new CodePrimitiveExpression(Table),
new CodePrimitiveExpression("SUM"),
new CodeArgumentReferenceExpression("field"),
new CodeArgumentReferenceExpression("DISTINCT"),
new CodeArgumentReferenceExpression("expression"),
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(Name), "mGroupString"))));
count = new CodeMemberMethod();
count.Name = "SUM";
count.ReturnType = new CodeTypeReference(typeof(object));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.IConnectinContext(), "context"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(string)), "field"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.WhereBody(), "expression"));
count.Attributes = MemberAttributes.Public | MemberAttributes.Static;
mEntity.Members.Add(count);
count.Statements.Add(
new CodeMethodReturnStatement(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(
new CodeTypeReferenceExpression(Name), "SUM"),
new CodeArgumentReferenceExpression("context"),
new CodeArgumentReferenceExpression("field"),
new CodePrimitiveExpression(false),
new CodeArgumentReferenceExpression("expression"))));
count = new CodeMemberMethod();
count.Name = "SUM";
count.ReturnType = new CodeTypeReference(typeof(object));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.IConnectinContext(), "context"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(string)), "field"));
count.Attributes = MemberAttributes.Public | MemberAttributes.Static;
mEntity.Members.Add(count);
count.Statements.Add(
new CodeMethodReturnStatement(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(
new CodeTypeReferenceExpression(Name), "SUM"),
new CodeArgumentReferenceExpression("context"),
new CodeArgumentReferenceExpression("field"),
new CodePrimitiveExpression(false),
new CodePrimitiveExpression(null))));
count = new CodeMemberMethod();
count.Name = "SUM";
count.ReturnType = new CodeTypeReference(typeof(object));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.IConnectinContext(), "context"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(string)), "field"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(bool)), "DISTINCT"));
count.Attributes = MemberAttributes.Public | MemberAttributes.Static;
mEntity.Members.Add(count);
count.Statements.Add(
new CodeMethodReturnStatement(
new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(
new CodeTypeReferenceExpression(Name), "SUM"),
new CodeArgumentReferenceExpression("context"),
new CodeArgumentReferenceExpression("field"),
new CodeArgumentReferenceExpression("DISTINCT"),
new CodePrimitiveExpression(null))));
CodeVariableDeclarationStatement context = new CodeVariableDeclarationStatement(TypeReferenceFactory.IConnectinContext(), "_context");
CodeAssignStatement setcontext = GetContext();
CodeTryCatchFinallyStatement trycatch;
CodeCatchClause _catch;
count = new CodeMemberMethod();
count.Name = "SUM";
count.ReturnType = new CodeTypeReference(typeof(object));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(string)), "field"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(bool)), "DISTINCT"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.WhereBody(), "expression"));
mEntity.Members.Add(count);
count.Statements.Add(context);
count.Statements.Add(setcontext);
trycatch = new CodeTryCatchFinallyStatement();
count.At
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -