element.cs
来自「smark.data是基于C#开发的轻量级数据访问组件。 提供以下功能封: 」· CS 代码 · 共 1,290 行 · 第 1/5 页
CS
1,290 行
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"), "OnCount"),
new CodeArgumentReferenceExpression("context"),
new CodePrimitiveExpression(Table),
new CodeArgumentReferenceExpression("expression"),
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(Name), "mGroupString"))));
CodeVariableDeclarationStatement context = new CodeVariableDeclarationStatement(TypeReferenceFactory.IConnectinContext(), "_context");
CodeAssignStatement setcontext = GetContext();
CodeTryCatchFinallyStatement trycatch;
CodeCatchClause _catch;
count = new CodeMemberMethod();
count.Name = "Count";
count.ReturnType = new CodeTypeReference(typeof(int));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.WhereBody(), "expression"));
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), "Count"),
new CodeVariableReferenceExpression("_context"),
new CodeArgumentReferenceExpression("expression"))));
_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 BuilderAVG()
{
CodeMemberMethod count = new CodeMemberMethod();
count.Name = "AVG";
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("AVG"),
new CodeArgumentReferenceExpression("field"),
new CodeArgumentReferenceExpression("DISTINCT"),
new CodeArgumentReferenceExpression("expression"),
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(Name), "mGroupString"))));
count = new CodeMemberMethod();
count.Name = "AVG";
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), "AVG"),
new CodeArgumentReferenceExpression("context"),
new CodeArgumentReferenceExpression("field"),
new CodePrimitiveExpression(false),
new CodeArgumentReferenceExpression("expression"))));
count = new CodeMemberMethod();
count.Name = "AVG";
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), "AVG"),
new CodeArgumentReferenceExpression("context"),
new CodeArgumentReferenceExpression("field"),
new CodePrimitiveExpression(false),
new CodePrimitiveExpression(null))));
count = new CodeMemberMethod();
count.Name = "AVG";
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), "AVG"),
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 = "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"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.WhereBody(), "expression"));
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 CodeArgumentReferenceExpression("expression"))));
_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")));
count = new CodeMemberMethod();
count.Name = "AVG";
count.ReturnType = new CodeTypeReference(typeof(object));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(string)), "field"));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
TypeReferenceFactory.WhereBody(), "expression"));
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 CodePrimitiveExpression(false),
new CodeArgumentReferenceExpression("expression"))));
_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")));
count = new CodeMemberMethod();
count.Name = "AVG";
count.ReturnType = new CodeTypeReference(typeof(object));
count.Parameters.Add(
new CodeParameterDeclarationExpression(
new CodeTypeReference(typeof(string)), "field"));
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 CodePrimitiveExpression(false),
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")));
count = new CodeMemberMethod();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?