private void WriteGetListCommon(IEnumerable <Parameter> methodParameters, string innerJoinClause, string columnsToReturn)
        {
            WriteGetListMethodSummary(methodParameters);
            var methodSignature = CodeWriterUtils.GetGetListMethodSignature(table, codeWriterSettings, methodParameters);

            using (classBuilder.BeginNest($"public {methodSignature}"))
            {
                CodeWriterUtils.WriteEntryLogging(classBuilder, methodSignature);
                var sqlCommandText = ConstructSqlQuery(methodParameters, innerJoinClause, columnsToReturn);
                classBuilder.AppendLine($"var entities = new List<{table.NetName}>();");
                WriteBeginCreateConnection();
                WriteBeginCreateCommand();
                classBuilder.AppendLine($"command.CommandText = {sqlCommandText};");
                WriteAddParametersToCommand(methodParameters);
                WriteBeginExecuteReader();
                WriteBeginReadReaderMultiple();
                classBuilder.AppendLine($"var entity = ({table.NetName}){_serviceProviderFieldName}.GetService(typeof({table.NetName}));");
                WriteParseEntityFromReader("entity");
                classBuilder.AppendLine("entities.Add(entity);");
                classBuilder.EndNest();
                classBuilder.EndNest();
                classBuilder.EndNest();
                classBuilder.EndNest();
                classBuilder.AppendLine("");
                classBuilder.AppendLine("return entities;");
                CodeWriterUtils.WriteExitLogging(classBuilder, methodSignature);
            }

            classBuilder.AppendLine("");
        }
示例#2
0
        private void WriteGetLists()
        {
            classBuilder.AppendLine($"{CodeWriterUtils.GetGetListMethodSignature(table, codeWriterSettings, CodeWriterUtils.GetGetListMethodParameters(table, codeWriterSettings, false))};");
            var methodParametersByCustomer = CodeWriterUtils.GetGetListMethodParameters(table, codeWriterSettings, true);

            if (methodParametersByCustomer == null || !methodParametersByCustomer.Any())
            {
                return;
            }

            classBuilder.AppendLine($"{CodeWriterUtils.GetGetListMethodSignature(table, codeWriterSettings, methodParametersByCustomer)};");
        }